Unable to run Docker from inside Docker

Expected behavior

docker command should work from within docker

Actual behavior

It gives an error


Here is my session log

C:\docker\nfs_mount>docker -v
Docker version 1.11.1, build 5604cbe

C:\docker\nfs_mount>docker run --privileged=true -v /usr/bin/docker:/bin/docker -it alpine /bin/sh
/ # docker -v
Docker version 1.11.1, build 8b63c77
/ # which docker
/ # docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
/ #

I don’t know a solution, but this: Docker-in-docker vs mounting /var/run/docker.sock
and this: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ may be of interest.

I think I tried this and it worked fine, see here.

-v /var/run/docker.sock:/var/run/docker.sock
1 Like

Friism, your command helped. I had to add docker binary too.

For community benefit, final command that works for me is

docker run --privileged=true -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/bin/docker -it alpine /bin/sh

once inside docker, use
docker images

and it should show all images

1 Like