Docker in Docker Container

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
  1. 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

  2. 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