When starting a Linux container (details below). I am seeing success with docker run ...
but docker-compose up
fails complaining about the bind mount path. It feels like docker run
is bind mounting the volume to the linux VM (via Hyper V)
Docker Compose Error
Cannot create container for service registrator: b'Mount denied: The source path "\\var\\run\\docker.sock:/tmp/docker.sock" is not a valid Windows path'
Here are details about how I am starting the container:
Docker Run (works as expected):
docker run --network=host --volume=/var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator consul://localhost:8500
Docker Compose:
registrator:
image: gliderlabs/registrator
command: "consul://consul:8500"
network_mode: host
volumes:
- /var/run/docker.sock:/tmp/docker.sock
OS: Windows 10 1709 (OS Build 16299.371) Docker for Windows: 18.04.0-ce Docker Compose: 1.21.0
I've been working on this for way too long. Asked a question here and then found my answer moments later. Sigh I hope what I learned can help someone.
I came across docker compose GitHub Issue #4303 where one of the pieces of guidance was to set this environment variable:
SET COMPOSE_CONVERT_WINDOWS_PATHS=1
Doing this in the shell where docker-compose up
is being invoked makes compose behave like run does. The container is now bind mounting the Linux VM host path rather than trying to map the windows host path. Which to me doesn't makes sense but heck it works.
From the Compose docs:
COMPOSE_CONVERT_WINDOWS_PATHS Enable path conversion from Windows-style to Unix-style in volume definitions. Users of Docker Machine and Docker Toolbox on Windows should always set this. Defaults to 0. Supported values: true or 1 to enable, false or 0 to disable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With