Docker volumes on Windows 10

Viewed 5944

I'm starting using Docker 17.09 hyper-v and my machine runs Windows 10 Pro. So far I managed to create the image and run the website I'm working on. My problem is mouting a volume. This is how I start the container:

docker run -p 81:80 -v C:/Users/Andre Luiz/Documents/Projects/dockerTest/src:/var/www/html php5.6

I also tried this:

docker run -p 81:80 -v //c/users/andre luiz/documents/projects/dockertest/src:/var/www/html php5.6

Trying to find the answer I found that I should enable shared drivers (Settings -> Shared Drivers and enable the driver). I did so and so far it doesn't work and I keep getting this message: invalid reference format: repository name must be lowercase.

Would you know what I'm missing or Docker simply doesn't mount volumes on windows?

Thanks for any help

2 Answers

I found the issue, this is the command that works:

docker run -p 81:80 -v c:/Projects/dockerTest/src/:/var/www/html/ php5.6

The problem was the whitespace in the path. So basically you can use only [a-zA-Z0-9][a-zA-Z0-9_.-] characters in the path, as described in this link: https://github.com/moby/moby/issues/25599

You don't have to rename the directory to avoid using spaces. You can use short names. Every Windows file/directory has two names - a long name that you see and a short name for compatibility. Program Files, for example, is usually PROGRA~1. To view those short names use dir /x in the Command Prompt.

C:\>dir /x
 Volume in drive C is OS
 Volume Serial Number is 220E-7DE8

 Directory of C:\

10/17/2017  11:05 PM    <DIR>          PROGRA~1     Program Files
11/03/2017  02:11 PM    <DIR>          PROGRA~2     Program Files (x86)
10/17/2017  11:06 PM    <DIR>                       Users
10/31/2017  07:12 PM    <DIR>                       Windows
10/31/2017  10:04 AM    <DIR>                       Windows.old
04/11/2017  11:05 AM    <DIR>          WINDOW~1     Windows10Upgrade

That fourth column is the short name. If there is no short name, the long name should be good enough.

Related