Docker Community Forums

Share and learn in the Docker community.

What's the correct way to mount a volume on Docker for Windows?


(Limeade) #1

I’ve looked at a few similar issues and bugs online, but so far none of them have helped. What’s the correct way to mount a volume in a container running on Docker for Windows? I’m running Docker 18.06.1-ce on Windows 10 (Latest). First, I create a local directory called C:\DeleteMe, and did a docker pull hello-world for testing. I would like to mount the contents of DeleteMe in a directory on the container called Data.

I first tried:

docker run -it -v C:\DeleteMe:/Data hello-world cmd

But I got back:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: invalid volume specification:
‘C:\DeleteMe:/Data’. See ‘C:\Program
Files\Docker\Docker\Resources\bin\docker.exe run --help’.

I also tried:

-v C:\DeleteMe:/Data hello-world cmd
-v C:\DeleteMe:/c/Data hello-world cmd
-v C:\DeleteMe:/c:/Data hello-world cmd
-v C:\DeleteMe:/c:\Data hello-world cmd

And about every other variety I could think of with various front slashes and back slashes for each. All have the same error message.

I’ve also tried the --mount syntax:

docker run -it --mount source=C:\DeleteMe,target=/Data hello-world cmd

And got a similar error:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: invalid mount config for type “volume”: invalid
mount path: ‘/Data’. See ‘C:\Program
Files\Docker\Docker\Resources\bin\docker.exe run --help’.

What’s the secret?


(Pfloosy) #2

I am using:

-v "C:\Docker\mysql-server:C:\db"

for my mssql container. Where C:\Docker\mssql-server is my local dir. C:\db will be automatically created in my container. / is used in linux only