Is Docker in Docker Container Possible?
In previous versions (around 2013), it seems jpetazzo/dind was available. Now it causes errors.
Mount docker.sock
The theory is that you should mount the host’s docker.sock.
I don’t really understand what I’m doing at this point, but I got it working, so here’s a memo.
-v /var/run/docker.sock:/var/run/docker.sock is the key.
Like this.
(yuis/env:1.0 can be replaced with ubuntu or left as is)
sudo docker run -it --rm -v /doc:/doc -v /var/run/docker.sock:/var/run/docker.sock yuis/env:1.0 sh -c "apt-get update ; apt-get install docker.io -y ; bash"
Check after entering the container. Docker commands can now be used inside the docker container.
root@4d7be4c1665a:/# docker run -it --rm yuis/env:1.0
root@eb264a363e3f:/#
References:
- Using Docker-in-Docker for your CI or testing environment? Think twice.
- How to run Docker inside a container running on Docker for Mac? - Docker Desktop for Mac - Docker Community Forums
- How can i run docker command inside a docker container? - Open Source Projects / Open Source Registry API - Docker Community Forums