On Windows, bind-mount volumes behave differently in docker-compose than docker run
NickName:KevM Ask DateTime:2018-04-14T01:19:04

On Windows, bind-mount volumes behave differently in docker-compose than docker run

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

Copyright Notice:Content Author:「KevM」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49822178/on-windows-bind-mount-volumes-behave-differently-in-docker-compose-than-docker

More about “On Windows, bind-mount volumes behave differently in docker-compose than docker run” related questions

On Windows, bind-mount volumes behave differently in docker-compose than docker run

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

Show Detail

Location of bind-mount volume provided in docker-compose file of mongodb

How to see the location of bind-mount volume provided in the docker-compose yml file. I have created an bind-mount to persist the mongodb. It is working fine i.e. if container is shut, then also th...

Show Detail

extract docker-compose file volumes with regex

I'm trying to extract all containers' bind-mounts/volumes of a docker-compose file with regex. The pattern that I've made for such purpose is: /volumes:\n(?:^[ \n]+- ?(\S+))/gm Regex Demo But it only

Show Detail

Docker-compose and volumes

When I create a volume manually and include it in docker-compose, if I don't prefix the volume tag with docker_, docker compose creates a new volume prefixed with docker_ For example: I create a vo...

Show Detail

volumes in docker run Vs. docker-compose

env: I am using Docker for Mac in my docker-compose file: client: stdin_open: true build: dockerfile: Dockerfile.dev context: ./client volumes: - /app/node_modules ...

Show Detail

docker-compose working but docker run not

I have a docker-compose with just one image. This is the docker-compose.yml definition: services: myNodeApp: image: "1234567890.dkr.ecr.us-west-1.amazonaws.com/myNodeApp:latest&quo...

Show Detail

Volumes not mounting with docker-compose on docker toolbox for windows

I initially configured my docker setup for Docker for Windows. Everything worked great. I'm using docker-compose to define 3 containers, each of which have a volume being mapped from my ./src (path...

Show Detail

Jenkins pipeline docker-compose mount volumes

I want to run a docker-compose in my Jenkins pipeline. My docker-compose needs to the current workspace source code. Jenkins cannot mount the volumes. What is missing? pipeline { agent any stages...

Show Detail

docker-compose using old volumes

I am trying to set up a CI pipeline with docker-compose and am struggling to understand how named volumes work... As part of my Dockerfile, I copy in the application files and then run composer in...

Show Detail

Make Dockerfile VOLUME behave like docker-compose volumes

I am trying to setup a Dockerfile to mount my host directory to my specified docker container directory (so code changes will be reflected immediately). When I run docker run -p 3000:3000 -d -v ~/

Show Detail