Docker Community Forums

Share and learn in the Docker community.

Bind mount not copying files to container

docker

(Jescos) #1

Hello everyone,

When I try mounting a bind volume using the command docker run --rm -it --mount type=bind,source=/c/Users/My_username/docker/test/src/,target=/data alpine sh Running ls -la /data in the container results in the following:

/ # ls -la /data
total 0
drwxr-xr-x 2 root root 40 Aug 22 10:40 .
drwxr-xr-x 3 root root 60 Aug 22 10:40 ..

No files are present within the container, even though there is a file in the folder on the host machine:

PS C:\Users\My_username\docker\test> ls c:/Users/My_username/docker/test/src/
Directory: C:\Users\My_username\docker\test\src
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 22/08/2018 21:25 50 index.php

I expected index.php to be inside the /data folder on the container. Using any other way of writing the source path (e.g. C:/Users, c:/Users, c/Users) results in an error. My C drive is set to be shared in the settings under Shared Drives. I am using docker version 18.06.0-ce, build 0ffa825 on Windows 10.

How can I make sure the files in the source folder get copied over to the container?