Skip to content

Instantly share code, notes, and snippets.

@thom4parisot
Last active August 29, 2015 14:12
Show Gist options
  • Save thom4parisot/81fd3a5849890169e25b to your computer and use it in GitHub Desktop.
Save thom4parisot/81fd3a5849890169e25b to your computer and use it in GitHub Desktop.
Docker instance sharing with boot2docker

Why we do that?

Because /var/run/docker.sock is not directly available on a machine running boot2docker.

How do we do that?

docker build -t shared-docker-env .
docker run -ti --rm -v ~/.boot2docker/certs/boot2docker-vm:/root/.docker -v $(which docker):/usr/bin/docker -e DOCKER_HOST=$DOCKER_HOST shared-docker-env
  1. -v ~/.boot2docker/certs/boot2docker-vm:/root/.docker injects your boot2docker TLS certificates;
  2. -v $(which docker):/usr/bin/docker injects the docker client in the container;
  3. -e DOCKER_HOST=$DOCKER_HOST shares the docker daemon HTTP URL (eg: tcp://192.168.59.103:2376) – enclosed in the boot2docker VM.

Then the CMD ["docker", "--tlsverify", "ps"] statements ensures the connection is made through HTTP instead of the UNIX socket, implicitly using the certificates located in the /root/.docker folder.

FROM busybox
CMD ["docker", "--tlsverify", "ps"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment