Skip to content

Instantly share code, notes, and snippets.

@krichardsson
Created July 10, 2015 14:31
Show Gist options
  • Save krichardsson/f35d954cdd114833331d to your computer and use it in GitHub Desktop.
Save krichardsson/f35d954cdd114833331d to your computer and use it in GitHub Desktop.
Docker in docker
One way to enable a docker container to use docker, is to pass the socket for the docker daemon to the container. To make it work you need to:
1. use a container that has the docker cli installed. A dockerfile for that
FROM debian
RUN apt-get update && apt-get install wget -y
RUN wget https://get.docker.io/builds/Linux/x86_64/docker-latest -O /bin/docker
RUN chmod +x /bin/docker
2. mount the docker daemon socket when the container is started docker
run -it --rm -v /var/run/docker.sock:/var/run/docker.sock myDockerEnabledImage bash
3. The user in the container must have rights to use the socket. For root there is no problem but to enable it for for other users, use chmod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment