Mount /var/lib/docker for Docker for Windows

Expected behavior

I would ike to mount a folder from the actual Dcoker installation in Docker container. In Linux I could do this for example using --volume=/var/lib/docker/:/var/lib/docker:ro

Actual behavior

In Windows this leads to an error as /var/lib/docker is of course not a proper path. Question is: how can I mount such folder (which I understand are in the moby VM in Hyper-v)

Ok, the issue was that I was starting docker from my Git Bash in Windows 10. When running from CMD it worked as advertised.

Git bash will still work, however it escapes paths “helpfully”. One “fix” for this is to use a double slash. For example:

winpty docker run --rm -it --name docker-toolbox -v //var/run/docker.sock://var/run/docker.sock:ro -v //var/lib/docker://var/lib/docker:ro -v //d/projects://mnt/projects -v //://mnt/host gavinjonespf/docker-toolbox:latest bash

Also, using git bash you’ll need to use winpty if you need to check docker containers interactively (-it).

Gav

1 Like

Thanks Gav, very useful information. I’d love to “stay in bash”…