I am trying to run a container inside another container using Docker inside docker https://hub.docker.com/_/docker.
When I run the following:
docker run --privileged docker:stable-dind docker run hello-world
I get the following error message:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'.
I must be missing something, how can I run docker inside docker?
I don't think you can do this in a one-liner (others might correct me). However, as explained at hub.docker.com/_/docker/, you can start the a docker-in-docker container as a background daemon (
-d
) and then start other containers inside.To start the parent container, run
The name
some-docker
is arbitrary. It will be used to identify this container later on. To start a container inside, runThe
--link
option exposes the network ports of the parent container and sets environment variables, such that the inner container uses docker from the dind image.