If the Docker socket is mounted a container fails to start

docker

#1

Running a golang container and mounting the docker socket fails with error code 255:

$ docker run -ti -v /var/run/docker.sock:/var/run/docker.sock golang sh
$ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED              STATUS                          PORTS               NAMES
6b2156aacfba        golang                     "sh"                     2 minutes ago        Exited (255) 3 seconds ago                          ecstatic_shaw

I haven’t spotted any clue in the Docker daemon log except:

ERRO[1422] Handler for POST /v1.21/containers/ecstatic_shaw/resize returned error: Container 6b2156aacfba3655f9c37109e142125242c97cdd5f3b480d802bd6d39cfbe159 is not running
ERRO[1422] HTTP Error err=Container 6b2156aacfba3655f9c37109e142125242c97cdd5f3b480d802bd6d39cfbe159 is not running statusCode=500

The same happens if running debian or ubuntu containers. But using busybox or alpine works :

$ docker run -v /var/run/docker.sock:/var/run/docker.sock alpine sh
# exit
$ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED              STATUS                          PORTS               NAMES
9f28398ed377        alpine                     "sh"                     About a minute ago   Exited (0) About a minute ago                       tiny_babbage

Sharing `/usr/bin/docker` and `/usr/var/docker.sock`
#2

Confirmed on my side as well:

docker run -v /var/run/docker.sock ubuntu:14.04 echo hi || echo $?

This will no-op and return a 255 error code. But if I don’t mount the Docker socket:

docker run ubuntu:14.04 echo hi || echo $?

This runs normally and prints “hi”.


#3

This issue does not appear to be occurring for CircleCI containers using the Docker 1.10.0 beta configuration.


#4