Mounting a host directory as a data volume doesn't work as expected

Expected behavior

When listing the files of a mounted volume in the container, the files from the host directory should be listed

Actual behavior

The mounted volume appears to be empty

Information

Docker for Windows version: 1.10.6.958
Windows version: Microsoft Windows 10 Pro

Steps to reproduce the behavior

  1. Create a directory on the host named my_volume under c:\ and put a file in it.
  2. docker run -it -v /c/my_volume:/my_mnt alpine /bin/sh
  3. Inside the alpine container: ls /my_mnt/

Found the answer here
Only the C:\Users area of the host file system is shared with the container and thus mountable.
So running docker run -it -v /c/Users/Christian/my_volume:/my_mnt alpine /bin/sh works.

1 Like

Interesting because when I type docker run --rm -ti -v /c/Users/xtof/Desktop:/desktop alpine ash I have an empty /desktop directory in the container.

OK now Iā€™m officially confused.
I made a clean install of Windows 10 and D4W and now when I run
docker run -it -v /c/Users/Christian/my_volume:/my_mnt alpine /bin/sh
I get the same issue as before i.e. the mounted directory is empty.

@chribben with D4W, all of your c-drive is mountable in containers (weā€™re working on supporting other drives too).

Can you confirm that drive-sharing is enabled in settings?

I tried to reproduce your problem on my machine, but cannot. Neither with a folder (with content) in C:\code nor as a sub-folder in my userā€™s folder. Both existing and non-existing folders work correctly (the non-existing ones are empty).

If the above doesnā€™t solve the problem, can you try running the DockerDebugInfo.ps1 in C:\<program files>\Docker\Docker\resources?

Michael

Enabling it makes mounting work, thanks!

I hadnā€™t enabled drive sharing, somehow I thought this option should be enabled only if you wanted to share other folders than C:\Users.

Hi,

in my setup, I have a local user ā€œdemoā€ on my Windows host which I use for the shares

I enabled the share for D Drive in d4w beta - settings and run the following commands (which work perfectly for my boot2docker+hyper-v setup) from my project folder (contains index.html):

Commands:

docker ps -a

docker rm webserver

docker run -p 80:80 -d --name webserver -v D:\prj\docker-tallinn:/usr/share/nginx/html/ nginx:alpine

docker exec -it webserver /bin/sh

ls -l /usr/share/nginx/html/

>total 0

$(iwr docker).Content

>iwr : 403 Forbidden
>nginx/1.9.14

Logs:

PS C:\WINDOWS\system32> gc $env:LocalAppData\Docker\log-2016-04-17_06-13-04.txt -Wait
[06:13:04.967][Program        ][Info   ] Version: Version 1.11.0-beta7 (build: 1692)
[06:13:04.970][Program        ][Info   ] Starting on: 4/17/2016 6:13:04 AM
[06:13:04.972][Program        ][Info   ] Resources: C:\Program Files\Docker\Docker\Resources
[06:13:04.975][Program        ][Info   ] OS: Windows 10 Enterprise Insider Preview
[06:13:04.978][Program        ][Info   ] Edition: Enterprise
[06:13:04.994][Program        ][Info   ] Id: 1511
[06:13:04.996][Program        ][Info   ] Build: 14316
[06:13:04.999][Program        ][Info   ] BuildLabName: 14316.1000.amd64fre.rs1_release.160402-2217
[06:13:05.004][Program        ][Info   ] Id: 1f40c2b3-1a74-4e83-a8f9-2ee0932ab47d
[06:13:05.009][Program        ][Info   ] Sha1: 8b45bc3afc0ca2363890032ac63b003d80ccc242
[06:13:05.011][Program        ][Info   ] You can send feedback, including this log file, at https://forums.docker.com/c/docker-for-windows
[06:13:05.051][HyperV         ][Info   ] Checking for Hyper-V Windows optional feature
[06:13:05.062][PowerShell     ][Info   ] Run script...
[06:13:05.518][HyperV         ][Info   ] Hyper-V Windows feature is enabled
[06:13:05.706][Authentication ][Info   ] Checking token
[06:13:05.950][Authentication ][Info   ] Token is valid
[06:13:05.962][Auth           ][Info   ] Retrieved credentials: demo:***********
[06:13:05.968][Firewall       ][Info   ] Opening TCP ports on the firewall for C:\Program Files\Docker\Docker\Resources\com.docker.proxy.exe...
[06:13:05.971][PowerShell     ][Info   ] Run script...
[06:13:06.287][Updater        ][Info   ] Checking for updates on the Beta channel...
[06:13:07.445][Firewall       ][Info   ] Ports opened
[06:13:07.448][Firewall       ][Info   ] Opening UDP ports on the firewall for C:\Program Files\Docker\Docker\Resources\com.docker.proxy.exe...
[06:13:07.518][PowerShell     ][Info   ] Run script...
[06:13:08.024][Updater        ][Info   ] Found remote version. Version = 1.11.0.1692
[06:13:08.027][Updater        ][Info   ] Local version is up to date.
[06:13:08.030][Updater        ][Info   ] Check for update done.
[06:13:08.187][Firewall       ][Info   ] Ports opened
[06:13:08.191][HyperV         ][Info   ] Creating a virtual machine named MobyLinuxVM
[06:13:08.194][HyperV         ][Info   ] Checking for Hyper-V Windows optional feature
[06:13:08.196][PowerShell     ][Info   ] Run script...
[06:13:08.518][HyperV         ][Info   ] Hyper-V Windows feature is enabled
[06:13:08.526][PowerShell     ][Info   ] Run script with parameters: -Create True -IsoFile C:\Program Files\Docker\Docker\Resources\mobylinux.iso...
[06:13:11.404][HyperV         ][Info   ] Using existing Switch: DockerNAT
[06:13:11.479][HyperV         ][Info   ] Using existing: MobyLinuxVM
[06:13:11.487][Proxy          ][Info   ] Starting com.docker.proxy
[06:13:11.594][HyperV         ][Info   ] Start a virtual machine named MobyLinuxVM
[06:13:11.598][HyperV         ][Info   ] Checking for Hyper-V Windows optional feature
[06:13:11.602][PowerShell     ][Info   ] Run script...
[06:13:11.635][Proxy          ][Info   ] 2016/04/17 06:13:11 dhcp server: ready
[06:13:11.652][Proxy          ][Info   ] 2016/04/17 06:13:11 poison pill: ready
[06:13:11.656][Proxy          ][Info   ] 2016/04/17 06:13:11 docker proxy: ready
[06:13:11.659][Proxy          ][Info   ] 2016/04/17 06:13:11 dns server: ready
[06:13:11.663][Proxy          ][Info   ] 2016/04/17 06:13:11 docker proxy (on deprecated port): ready
[06:13:11.954][HyperV         ][Info   ] Hyper-V Windows feature is enabled
[06:13:11.957][PowerShell     ][Info   ] Run script with parameters: -Start True...
[06:13:13.356][HyperV         ][Info   ] Removing com.docker.proxy firewall rules...
[06:13:13.635][HyperV         ][Info   ] Starting VM MobyLinuxVM...
[06:13:15.629][HyperV         ][Info   ] Wait for the VM to get an IP address
[06:13:19.275][Proxy          ][Info   ] 2016/04/17 06:13:19 dhcp: Discover from 00:15:5d:dd:01:36
[06:13:19.279][Proxy          ][Info   ] 2016/04/17 06:13:19 dhcp: Offering 10.0.75.2 to 00:15:5d:dd:01:36
[06:13:19.345][Proxy          ][Info   ] 2016/04/17 06:13:19 dhcp: Request from 00:15:5d:dd:01:36
[06:13:19.348][Proxy          ][Info   ] 2016/04/17 06:13:19 dhcp: Acking 10.0.75.2 to 00:15:5d:dd:01:36
[06:13:19.351][Proxy          ][Info   ] 2016/04/17 06:13:19 Invalidate cache
[06:13:26.346][HyperV         ][Info   ] Unmounting volumes /C;/c in a virtual machine named MobyLinuxVM
[06:13:26.349][HyperV         ][Info   ] Checking for Hyper-V Windows optional feature
[06:13:26.352][PowerShell     ][Info   ] Run script...
[06:13:26.681][HyperV         ][Info   ] Hyper-V Windows feature is enabled
[06:13:26.684][PowerShell     ][Info   ] Run script with parameters: -Unmount True -UnmountPoints /C;/c...
[06:13:28.108][HyperV         ][Info   ] Removing (potentially) existing mount authentication token
[06:13:28.471][SmbShare       ][Info   ] Testing connection to host filesystem
[06:13:28.534][HyperV         ][Info   ] Mounting volumes /D;/d in a virtual machine named MobyLinuxVM
[06:13:28.540][HyperV         ][Info   ] Checking for Hyper-V Windows optional feature
[06:13:28.547][PowerShell     ][Info   ] Run script...
[06:13:28.951][HyperV         ][Info   ] Hyper-V Windows feature is enabled
[06:13:28.955][PowerShell     ][Info   ] Run script with parameters: -Mount True -Credential System.Management.Automation.PSCredential -MountPoints /D;/d...
[06:13:30.465][HyperV         ][Info   ] Removing (potentially) existing mount authentication token
[06:13:30.742][HyperV         ][Info   ] Mounting host filesystem
[06:13:30.807][HyperV         ][Info   ] Mounting with user demo
[06:13:30.880][Notifications  ][Info   ] Docker is running
[06:15:48.067][Proxy          ][Info   ] 2016/04/17 06:15:48 proxy >> GET /v1.23/containers/json?all=1
[06:15:48.071][Proxy          ][Info   ] 2016/04/17 06:15:48 Dial 10.0.75.2:2375
[06:15:48.075][Proxy          ][Info   ] 2016/04/17 06:15:48 Lookup IP for 10.0.75.2:2375
[06:15:48.080][Proxy          ][Info   ] 2016/04/17 06:15:48 [10.0.75.2]
[06:15:48.084][Proxy          ][Info   ] 2016/04/17 06:15:48 Dial IP 10.0.75.2:2375
[06:15:48.089][Proxy          ][Info   ] 2016/04/17 06:15:48 proxy << GET /v1.23/containers/json?all=1
[06:15:53.102][Proxy          ][Info   ] 2016/04/17 06:15:53 proxy >> DELETE /v1.23/containers/webserver
[06:15:53.105][Proxy          ][Info   ] 2016/04/17 06:15:53 Dial 10.0.75.2:2375
[06:15:53.110][Proxy          ][Info   ] 2016/04/17 06:15:53 Dial IP 10.0.75.2:2375
[06:15:53.113][Proxy          ][Info   ] 2016/04/17 06:15:53 proxy << DELETE /v1.23/containers/webserver
[06:16:09.084][Proxy          ][Info   ] 2016/04/17 06:16:09 proxy >> POST /v1.23/containers/create?name=webserver [rewriteBinds]
[06:16:09.089][Proxy          ][Info   ] 2016/04/17 06:16:09 Rewrote mount to /D/prj/docker-tallinn:/usr/share/nginx/html/
[06:16:09.092][Proxy          ][Info   ] 2016/04/17 06:16:09 proxy >> POST /v1.23/containers/create?name=webserver
[06:16:09.095][Proxy          ][Info   ] 2016/04/17 06:16:09 Dial 10.0.75.2:2375
[06:16:09.097][Proxy          ][Info   ] 2016/04/17 06:16:09 Dial IP 10.0.75.2:2375
[06:16:09.429][Proxy          ][Info   ] 2016/04/17 06:16:09 proxy << POST /v1.23/containers/create?name=webserver
[06:16:09.435][Proxy          ][Info   ] 2016/04/17 06:16:09 proxy >> POST /v1.23/containers/9e113a6ed58daa540da9f98583c1692645cd4bf9df151b11a0dd2d081825583f/start [start]
[06:16:09.440][Proxy          ][Info   ] 2016/04/17 06:16:09 proxy >> POST /v1.23/containers/9e113a6ed58daa540da9f98583c1692645cd4bf9df151b11a0dd2d081825583f/start
[06:16:09.445][Proxy          ][Info   ] 2016/04/17 06:16:09 Dial 10.0.75.2:2375
[06:16:09.449][Proxy          ][Info   ] 2016/04/17 06:16:09 Dial IP 10.0.75.2:2375
[06:16:10.374][Proxy          ][Info   ] 2016/04/17 06:16:10 proxy << POST /v1.23/containers/9e113a6ed58daa540da9f98583c1692645cd4bf9df151b11a0dd2d081825583f/start
[06:16:15.921][Proxy          ][Info   ] 2016/04/17 06:16:15 proxy >> POST /v1.23/containers/webserver/exec
[06:16:15.927][Proxy          ][Info   ] 2016/04/17 06:16:15 Dial 10.0.75.2:2375
[06:16:15.932][Proxy          ][Info   ] 2016/04/17 06:16:15 Dial IP 10.0.75.2:2375
[06:16:15.937][Proxy          ][Info   ] 2016/04/17 06:16:15 proxy << POST /v1.23/containers/webserver/exec
[06:16:15.942][Proxy          ][Info   ] 2016/04/17 06:16:15 proxy >> POST /v1.23/exec/4865d07e7d332b62e186ca8c515758635716377eb3f3472e8fe36f81ae29af63/start
[06:16:15.946][Proxy          ][Info   ] 2016/04/17 06:16:15 Dial 10.0.75.2:2375
[06:16:15.949][Proxy          ][Info   ] 2016/04/17 06:16:15 Dial IP 10.0.75.2:2375
[06:16:15.953][Proxy          ][Info   ] 2016/04/17 06:16:15 Upgrading to raw stream
[06:16:15.956][Proxy          ][Info   ] 2016/04/17 06:16:15 proxy >> POST /v1.23/exec/4865d07e7d332b62e186ca8c515758635716377eb3f3472e8fe36f81ae29af63/resize?h=56&w=197
[06:16:15.961][Proxy          ][Info   ] 2016/04/17 06:16:15 Dial 10.0.75.2:2375

It appears that the ā€œRewrote mount to /D/prj/docker-tallinn:/usr/share/nginx/html/ā€ did not work as the contents of the mounted volume is blankā€¦

The setup works in Boot2Docker with the default Docker-Machine using the hyper-v driver (not using Docker-ToolBox), but it doesnā€™t work in d4w beta (which uses the hv_kvp_daemon to set {ā€œcifsmountā€; ā€œ/d;/D;username=$user,password=$pass,nopermā€} key-value pair for the alpine VM) Iā€™m unable to debug as I canā€™t SSH into MobyLinuxVM, itā€™s a total black box - which is very frustratingā€¦ (unable to set TLS, unable to set private registry, ā€¦)

Although, 1 difference between my boot2docker setup and my MobyLinuxVM is the fact that I had to set ā€œdomainā€ to my computer IP for the cifs mount to work as my laptop belongs to a domain and the demo user is local only.

I just tested that the following works

#get a privileged container with access to Docker daemon
docker run --privileged -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker alpine sh

#run a container with full root access to MobyLinuxVM and no seccomp profile
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh

#switch to host FS
chroot /host

#test mount the windows host folder
mount -t cifs //10.0.75.1/D /D -o user=demo,domain=10.0.75.1,pass=demo

I tried to use ā€œ10.0.75.1\demoā€ to force using the correct domain when entering the credentials for the share, but it didnā€™t seem to accept it, repeatedly prompting me for credentials.

I will try to update the Windows Credentials Manager directly to see if I can put the credentials there and if that fixes the issue - in which case the issue would be when D4W beta tries to validate the share credentialsā€¦

Iā€™m using Amazon AMI and same issue facing, Iā€™m using following docker command to run container but my /base/props is not mounting where my /home/props has files

docker run -d --name my-app -m 250MB -v /home/props:/base/props -p 8888:8888 my-app

Thats right. Also, under WSL, it only works by using the ā€˜/c/Users/ā€¦ā€™ paths. Using ā€˜/mnt/c/Users/ā€¦ā€™ paths makes the container mounted directory to be empty:

Doesnā€™t work correctly with WSL:

docker run -v /mnt/c/Users/myuser/folder:/var/sites/ --rm -it --entrypoint /bin/bash my-registry:7090/apache-image:1.0.0

[/var/sites directory looks empty inside the container]

Works OK with WSL:

docker run -v /c/Users/myuser/folder:/var/sites/ --rm -it --entrypoint /bin/bash my-registry:7090/apache-image:1.0.0

[/var/sites correctly mounted]