Docker executor fails to connect to Docker daemon using the Docker socket binding method

Summary

Gitlab runner docker executor fails to connect to docker daemon using the socket bind method described here.

Steps to reproduce

Start with a new installation (debian package) of gitlab runner. Register the runner using

sudo gitlab-ci-multi-runner register -n \
  --url https://XXXXXXXXX/ci \
  --registration-token XXXXXXXXXXXXX \
  --executor docker \
  --description "My Docker Runner" \
  --docker-image "docker:latest" \
  --docker-volumes /var/run/docker.sock:/var/run/docker.sock

Have a minimum working example .gitlab-ci.yml:

image: docker:latest

before_script:
  - docker info

build:
  stage: build
  script:
    - /bin/true

Execute the runner locally running build stage:

sudo gitlab-runner exec docker build

Actual behavior

Using docker image sha256:c27603bc4d9c5845b59f772b7ff7512c37379fc60171bd072d5ff64fc63e17b2 for predefined container...
Pulling docker image docker:latest ...
Using docker image docker:latest ID=sha256:192e3edb771f334fbc2e1941b22a0b3ecd8545a86744ce8fc2fe98a3d5774273 for build container...
Running on runner--project-0-concurrent-0 via ubook...
Cloning repository...
Cloning into '/builds/project-0'...
done.
Checking out 6e57f834 as master...
Skipping Git submodules setup
$ docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Running after script...
ERROR: Job failed: exit code 1
FATAL: exit code 1

Expected behavior

Seeing the output of docker info as it would have been executed on the host.

Environment description

Output of cat /etc/gitlab-runner/config.toml:

concurrent = 1
check_interval = 0

[[runners]]
  name = "My Docker Runner"
  url = "https://XXXXXXXXX/ci"
  token = "XXXXXXXXXX"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
  [runners.cache]

Output of docker run -v /var/run/docker.sock:/var/run/docker.sock --rm -it docker:latest docker info:

Containers: 22
 Running: 1
 Paused: 0
 Stopped: 21
Images: 169
Server Version: 17.06.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 220
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-83-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.392GiB
Name: ubook
ID: N3HB:ATQ6:2RIW:7J6J:7YMO:QYFB:AQEO:SLGR:FCXR:G3PD:W5WZ:2GGG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Used GitLab Runner version

Running with gitlab-ci-multi-runner 9.3.0 (3df822b)
  on  ()
Using Docker executor with image docker:latest ...

As demonstrated, the basic mechanism of binding the docker socket to a container works. I also tried the other dind method described here and end up with the same problem. Please let me know if I should create a second issue for the dind-problem.