for-win icon indicating copy to clipboard operation
for-win copied to clipboard

docker-compose bind mount docker.sock not a valid Windows path

Open andymeierdev opened this issue 8 years ago • 66 comments

Expected behavior

Should be able to bind mount the docker socket as explained in http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ using docker-compose

Actual behavior

I can successfully run the command

docker run -v /var/run/docker.sock:/var/run/docker.sock -it docker

But when I try to use within a docker-compose.yml file I get the following error

Creating docker_docker_1 ... error

ERROR: for docker_docker_1  Cannot create container for service docker: b'Mount denied:\nThe source path "\\\\var\\\\run\\\\docker.sock:/var/run/docker.sock"\nis not a valid Windows path'

ERROR: for docker  Cannot create container for service docker: b'Mount denied:\nThe source path "\\\\var\\\\run\\\\docker.sock:/var/run/docker.sock"\nis not a valid Windows path'
ERROR: Encountered errors while bringing up the project.

Information

Docker Community Edition

Version 18.03.0-ce-rc3-win56 (16433)
Channel: edge
b6990be

Note: Just updated Docker and I did not receive this error in previous version.

docker-compose.yml

version: '3'
services:
    docker:
        image: docker
        stdin_open: true
        tty: true
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock

Running docker-compose up gives the following error

λ  docker-compose up
Creating docker_docker_1 ... error

ERROR: for docker_docker_1  Cannot create container for service docker: b'Mount denied:\nThe source path "\\\\var\\\\run\\\\docker.sock:/var/run/docker.sock"\nis not a valid Windows path'

ERROR: for docker  Cannot create container for service docker: b'Mount denied:\nThe source path "\\\\var\\\\run\\\\docker.sock:/var/run/docker.sock"\nis not a valid Windows path'
ERROR: Encountered errors while bringing up the project.

Steps to reproduce the behavior

  1. Run docker-compose up using above docker-compose.yml

andymeierdev avatar Mar 13 '18 20:03 andymeierdev

Reverting to

Version 17.12.0-ce-win47 (15139)
Channel: stable
9c692cd

works without an error.

andymeierdev avatar Mar 13 '18 21:03 andymeierdev

THis is critical for us, too!

ChristianSauer avatar Mar 14 '18 07:03 ChristianSauer

@ameier38 Where can I find this older verison of docker?

ChristianSauer avatar Mar 14 '18 07:03 ChristianSauer

@ChristianSauer Go to install page and then download the stable channel.

andymeierdev avatar Mar 14 '18 12:03 andymeierdev

It would be really helpful for us Edge users if you could keep the previous Edge versions available for download so when something fundamental like this breaks we can just roll back one Edge release, instead of having to revert all the way back to Stable.

ThatRendle avatar Mar 14 '18 15:03 ThatRendle

You can download previous versions from this page https://docs.docker.com/docker-for-windows/release-notes/

creativearmenia avatar Mar 14 '18 17:03 creativearmenia

@creativearmenia So you can, I missed that. Thank you!

ThatRendle avatar Mar 14 '18 20:03 ThatRendle

It's still an issue in 18.03.0-ce-rc4

wailua avatar Mar 15 '18 17:03 wailua

The windows version of docker doesn't use unix socket (/var/run/docker.sock) but npipe (npipe:////./pipe/docker_engine). So you have either

  • to switch to linux container which runs docker in a full virtualized linux with unix socket
  • to pass the npipe instead of the unix socket to the container (windows container only)
  • to use a network socket (should work with linux and windows container)

The doc is here : https://docs.docker.com/docker-for-windows/faqs/#how-do-i-connect-to-the-remote-docker-engine-api

stalb avatar Mar 20 '18 11:03 stalb

@stalb This is not about connecting to the API, it's about mounting the /var/run/docker.sock unix socket (from the Hyper-V host Linux VM) into a running container.

ThatRendle avatar Mar 20 '18 14:03 ThatRendle

Looks like this issue is in stable now, and just wiped out an environment that uses an nginx proxy, listening to docker.sock to auto-proxy sites.

https://github.com/jwilder/nginx-proxy

Docker Version: 18.03.0-ce-win59

johnrom avatar Mar 26 '18 14:03 johnrom

We are getting into same issues on stable driver, when can we get fix for this.? Do we need to switch back to previous stable release.? Is there a workaround for this until we get fix in next stable driver.?

jagraj avatar Mar 26 '18 15:03 jagraj

@jagraj I reverted to the last version, 17.12.0-ce-win47, for now. I wasn't able to identify any workarounds or locate a docker.sock that was accessible from the host file system.

johnrom avatar Mar 26 '18 15:03 johnrom

I am wondering how this blocking issue ended up in stable release where customers already reported in edge drivers.

jagraj avatar Mar 26 '18 16:03 jagraj

Docker-for-Windows team: Please let us know that you've registered this critical regression! It's on track to break our product for Windows users.

rfay avatar Mar 26 '18 16:03 rfay

We've also had this reported for some of our Windows lando users.

pirog avatar Mar 26 '18 17:03 pirog

Docker For Windows updated to 18.03.0-ce-win59 (16762) on the stable channel today and I ran into this issue as well. Docker-compose is unable to bind to /var/run/docker.sock

a727891 avatar Mar 26 '18 17:03 a727891

I've managed to work around this issue by setting environment variable COMPOSE_CONVERT_WINDOWS_PATHS to something truthy (1, 'true', 'on') as per https://github.com/docker/compose/issues/4240. Release notes at the time suggest Docker for Windows did not need to set this but clearly this has now been broken, see https://github.com/docker/compose/blob/master/CHANGELOG.md#190-2016-11-16.

Issue seems to have been introduced by this commit https://github.com/docker/compose/commit/2fbec60c9c94e7f20c221a5f0ceaf49dbe612c3f, most likely https://github.com/docker/compose/commit/2fbec60c9c94e7f20c221a5f0ceaf49dbe612c3f#diff-e2ff86ffa7e639ddeff3723cabf428eeR150. Original PR - https://github.com/docker/compose/pull/5560

So this doesn't seem to be a Docker for Windows issue directly and probably should be fixed in compose?

jimgolfgti avatar Mar 26 '18 22:03 jimgolfgti

@jimgolfgti 's marvelous workaround in https://github.com/docker/for-win/issues/1829#issuecomment-376328022 is the ticket for us. Thanks so much for sharing that.

rfay avatar Mar 27 '18 15:03 rfay

The workaround from @jimgolfgti didn't work for me in Git for Windows 2.16.2.1 bash shell. Same error with and without the environment variable. Uninstalled d4w 18.x and installed 17.12.0-ce-win47 (15139), and now everything works as before.

shpros avatar Mar 27 '18 19:03 shpros