File not present in mounted volume. Also in mounted volume, only root has write permissions

Expected behavior

See the windows file in docker mounted volume. Also the directory should have write permissions to everyone.

Actual behavior

mounted directory is empty and only root has write permissions

Information

Here is my session log

C:\docker\nfs_mount>docker -v
Docker version 1.11.1, build 5604cbe

C:\docker\nfs_mount>dir /b
c.txt

C:\docker\nfs_mount>docker run -v c:/docker/nfs_mount:/nfs_mount alpine ls -lart /nfs_mount
total 4
drwxr-xr-x 2 root root 40 May 17 06:07 .
drwxr-xr-x 24 root root 4096 May 17 06:20 …
C:\docker\nfs_mount>

Steps to reproduce the behavior

  1. create a file with some text in it
  2. run following command “docker run -v c:/docker/nfs_mount:/nfs_mount alpine ls -lart /nfs_mount”

can’t see what’s the contents of my folder either. with last build 3073

nobody have still the link to the post with the solutions about accessing the files with that problem?

I was experiencing the same issue, but was fixed after adding C: to the shared drives as described in this reply: Volume mounts in windows does not work

yeah but already done that, not working. Well obviously not on C: because i’m on ssd so I don’t want to to use C: by definition and more the good old HDD .

I also posted this in the other thread, but duplicating here.

I found another problem, namely that “File and printer sharing” may be turned off. That causes volume mounting to silently fail for me.

It can be enabled in the GUI or with:

netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
1 Like

Note that this command is language dependent, but in a highly inconsistent way: In German Windows

netsh advfirewall firewall set rule group="Datei- und Druckerfreigabe" new enable=Yes
32 Regel(n) wurde(n) aktualisiert.

I think all previous replies have dealt with just the visibility part of the question (and correctly, through working out some quirks that can happen when sharing the host drive in docker settings).

As for the root write permissions… this is an ongoing issue in Docker for Windows even two years after this question. Docker for Windows apparently not only forces root permissions inside the guest for mounted host folders (in this it is no different from Docker for Linux or Mac) but furthermore, chown and chmod will not work even if you docker exec into a shell in the container. I read all I could on this last week and ultimately decided to simply quit beating my head against the bricks and stop using Docker for Windows for the time being. I have returned to running Docker strictly on Linux. And there are many side benefits of that, not least of which is that all of the docs and tutorials work without hidden gotchas and extra hours of discussion searching.

We can all hope that Docker for Windows will achieve more behavior parity in the future, but some aspects, like user/group/permission handling, just aren’t going to match up because of how different the Windows ACL system is. At some point the only thing that really handles that difference fully enough is another layer of abstraction – typically just running docker in a Linux VM, if forced to do your work on a machine that boots to Windows. I know that defeats much of the purpose of docker, but if it’s only one of your machines and you also develop elsewhere on your linux laptop (etc) then maybe it’s no big deal. For me, my desktop machines are powerful enough that my VMs feel almost native so it’s no big deal. And I still appreciate all the benefits of containerization even if I’m wasting just that one (the one about not needing to run a full VM).

I used the -v option suggested in this article - How to Mount Current Directory as a Volume in Docker on Windows 10?.

When you say permissions error, you can make permission changes in your Dockerfile or docker-compose.yml too (after the fact). Have you tried that?