Docker Community Forums

Share and learn in the Docker community.

Unable to run Docker from inside Docker

(Vinayagg) #1

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?
/ #

(Mario Pietsch) #2

I don’t know a solution, but this: Docker-in-docker vs mounting /var/run/docker.sock
and this: may be of interest.

(Michael Friis) #3

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

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

(Vinayagg) #4

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