On *nix systems, it is possible to bind-mount the docker socket from the host machine to the VM by doing something like this:
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
Is there an equivalent way to do this when running docker on a windows host?
I tried various combinations like:
docker run -v tcp://127.0.0.1:2376:/var/run/docker.sock ...
docker run -v "tcp://127.0.0.1:2376":/var/run/docker.sock ...
docker run -v localhost:2376:/var/run/docker.sock ...
none of these have worked.
Just to top it off on the answers provided earlier
When using docker-compose, one must set the
COMPOSE_CONVERT_WINDOWS_PATHS=1
by either:1) create a
.env
file at the same location as the project's docker-compose.yml file2) in the CLI
set COMPOSE_CONVERT_WINDOWS_PATHS=1
before running the docker-compose up command.
source
I never made it worked myself, but i know it works on windows container on docker for windows server 2016 using this technique: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
We actually have at the shop vsts-agents on windows containers that uses the host docker like that:
For Docker for Windows following seems to be working:
-v //var/run/docker.sock:/var/run/docker.sock
As the Docker documentation states:
With all that being said, you can still use the:
The first
/var/run/docker.sock
refers to the same path in yourboot2docker
virtual machine.For example, when I run my own Jenkins image using the following command in a Windows machine:
I can still talk to the Docker Daemon in the host machine using the typical
docker
commands. For example, when I rundocker ps
in the Jenkins container, I can see running containers in the host machine: