question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker for Windows volume mounts and docker.sock

See original GitHub issue

Mounting /var/run/docker.sock is no longer working in stable Docker for Windows with the latest update. There is an issue here: https://github.com/docker/for-win/issues/1829

I’m not sure whether the issue is that docker.sock file is no longer a reliable source for DFW, and if that is the case then the issue will have to be resolved here. However, if it’s a bug and it should still be able to mount docker.sock on the Docker for Windows side of things, this bug should resolve itself in a future update.

An example error is here:

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

Example docker-compose.yml:

front:
  restart: always
  image: jwilder/nginx-proxy
  volumes:
    - /var/run/docker.sock:/tmp/docker.sock
  ports:
    - "80:80"
    - "443:443"

Docker Version: 18.03.0-ce-win59

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:9

github_iconTop GitHub Comments

9reactions
johnromcommented, Nov 14, 2018

@padhie I think the misunderstanding is that setting this variable just happens to fix the problem by changing the way paths are parsed. It’s not mapping this path to Windows in any way. This directory doesn’t exist in Windows, it exists in the Hyper-V VM (Linux). Hopefully, this will help you understand. When you open Docker for Windows “Settings” and go to “Shared Drives”, it helps you demonstrate the shared drive is working by entering this command:

docker run --rm -v c:/Users:/data alpine ls /data

What it then does, is automatically changes C:/Users to /c/Users in the background to demonstrate that C:\Users is correctly mounted within the Linux VM, and passed on to the container you create. What it doesn’t tell you, is there is a way to prevent that from happening, and by doing that you can prove that you’re actually mounting the drive from Linux to the Container. Using two slashes allows you to circumvent this conversion.

docker run --rm -v //:/data alpine ls //data

Now you’ll see a Linux root directory, with folders like var, opt, etc.

docker run --rm -v //var/run:/data alpine ls //data

Now you’ll see that there is a docker.sock

6reactions
a727891commented, Mar 28, 2018

There was a workaround found in docker/for-win#1829

Add an this environment variable: COMPOSE_CONVERT_WINDOWS_PATHS = 1

Or from Powershell run $Env:COMPOSE_CONVERT_WINDOWS_PATHS=1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bind to docker socket on Windows - Stack Overflow
On *nix systems, it is possible to bind-mount the docker socket from the host machine to the VM by doing something like this:...
Read more >
Running Docker in Docker on Windows (Linux containers)
mounting a volume to allow access to the Docker socket; adding the root group to the Jenkins user. To install the Docker CLI...
Read more >
Bind mount docker.sock with Windows container #6813 - GitHub
I'm trying to mix Windows and Linux containers and as you might know, the latest version that it works properly is 2.2.0.3 (based...
Read more >
Volumes - Docker Documentation
New volumes can have their content pre-populated by a container. Volumes on Docker Desktop have much higher performance than bind mounts from Mac...
Read more >
Bind mounts - Docker Documentation
Bind mounts have limited functionality compared to volumes. When you use a bind mount, a file or directory on the host machine is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found