In Docker Toolbox for the Mac, there is a reasonable way to run Docker itself inside a Docker container. The use case is a CI workflow that produces Docker artifacts. There’s a pretty good discussion here: http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
In Docker on real Linux, it’s very easy, with just these volume mounts from the host to the CI container:
docker run ... \
-v $(which docker):/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
My question is, how to do the same with Docker for Mac? I’ve tried all variations I can think of of the Linux technique above. I can share the .sock between the host and the CI container, but not the Docker executable itself.
apt-get install docker.io, or whatever your distribution-specific equivalent is, inside your container; don’t try to bind-mount the executable. This should work:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:16.04 bash
apt-get install docker.io
(I’ve seen a couple of posts very recently on this exact topic that lead me to wonder whether Alpine binaries are actually compatible with other distributions; in this case because the Moby VM is Alpine and your other container probably isn’t, the other one where the container they were trying to run was Alpine. I know it’s a different libc.)
Got it! Many thanks for your speedy help.
I was running into the same issue. In fact that works with root user . However when using a different user e.g. jenkins (put into the docker group) it does not work any more. See http://serverfault.com/questions/805558/docker-client-in-a-docker-container-cant-access-docker-host.