Skip to content

Instantly share code, notes, and snippets.

@snallami
Created March 30, 2017 07:01
Show Gist options
  • Save snallami/e6c0b06c7963c35d3e9c3100f4e97d75 to your computer and use it in GitHub Desktop.
Save snallami/e6c0b06c7963c35d3e9c3100f4e97d75 to your computer and use it in GitHub Desktop.
Safe alternative: use the host Docker daemon from within a container
The simple solution to allow a container process to start another container is to share the Docker socket of the host with the container, doing something like this:
docker run -v /var/run/docker.sock:/var/run/docker.sock -d --name some_container some_image
Assuming that Docker is installed in the image invoked, then the Docker client run within that container will be communicating with the Docker daemon running on the host.
Any containers created from within some_container would actually be created by the same Docker daemon that created some_container itself. Those new containers would be sibling containers, siblings to some_container.
Now there should be no worries about data corruption from nested storage drivers, or shared access to the Docker image cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment