Docker Community Forums

Share and learn in the Docker community.

Mount /var/lib/docker for Docker for Windows


(Oliver Koeth) #1

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)


(Oliver Koeth) #2

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


(Gavin Jones) #3

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


(Oliver Koeth) #4

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