How to install docker in docker container?
I had a similar problem trying to install Docker inside a Bamboo Server image. To solve this:
- first remove the line: RUN docker run hello-world from your
Dockerfile
- The simplest way is to just expose the Docker socket, by bind-mounting it with the
-v
flag or mounting a volume usingDocker Compose
:
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
The easiest way is to use the official Docker-in-Docker images from https://hub.docker.com/_/docker/ with the :dind
tag (which is the successor of the project Hendrikvh already mentioned).
You definitely need to use the --priviledged
flag also:
docker run --privileged --name yourDockerContainerNameHere -d docker:dind
With that your Docker-in-Docker experiments should work - but be aware of the many stumbleblocks that could be in your way: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/