8

Docker Desktop for Mac started using osxfs for supporting volume mounting on MacOS. According to their page, a command like this should mount the ~/Desktop directory to the docker container:

docker run -it -v ~/Desktop:/Desktop r-base bash

Although I do see a Desktop directory as expected, its contents are empty:

root@80cb534e4eeb:/# ls
bin  boot  Desktop  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@80cb534e4eeb:/# ls Desktop/
root@80cb534e4eeb:/# exit
exit 

while there are definitely files in the Desktop directory locally

Users-MacBook-Pro:~ user$ ls Desktop/
Screen Shot 2019-03-25 at 10.34.58.png      Screen Shot 2019-03-25 at 22.26.10.png      Screen Shot 2019-03-27 at 07.34.55.png
Screen Shot 2019-03-25 at 10.35.59.png      Screen Shot 2019-03-25 at 22.26.11.png      Screen Shot 2019-03-28 at 15.14.48.png
Screen Shot 2019-03-25 at 22.26.08.png      Screen Shot 2019-03-25 at 22.47.32.png      Screen Shot 2019-04-05 at 09.26.12.png
Screen Shot 2019-03-25 at 22.26.10 1.png    Screen Shot 2019-03-27 at 07.34.33.png 

The /Users directory should be accessible according to the Preferences window. Seems like something is wrong with the docker configuration, but I haven't found any similar issues reported yet. Most issues related to osxfs are about IO performance. Any ideas on how to further solve/investigate this issue?

enter image description here

8
  • Can you try mount the root of the vm running docker as a volume and see if you can access the Desktop folder that way. Something like docker run --rm -v /:/vm_root --entrypoint=sh alpine -c 'ls -l /vm_root/Users/user/Desktop' Commented Apr 13, 2019 at 23:45
  • Tried, no files visible. Also tried to access the user directory ls -l /vm_root/Users/user in the same way, I see that the only folders there are the folders that I have already tried to mount (even one non-existing locally). Seems like the Users directory of the VM does not correspond to the one of the local file system. Commented Apr 14, 2019 at 7:05
  • Ok that is strange. Maybe try to do factory reset of docker for mac? feels like a docker for mac bug somewhere? does any of the paths you configure in the preferences work? Commented Apr 14, 2019 at 18:28
  • This did it. Thanks! It's not clear what could have caused this, I never got it to work after the first install of Docker. Commented Apr 15, 2019 at 7:10
  • Ok good! Should i write a proper answer even when we dont know the resason? Commented Apr 15, 2019 at 8:19

3 Answers 3

7

Docker factory reset in the preferences fixed the issue but the root cause is still unknown. One way of troubleshoot this kind of issues is to volume mount the root of the linux VM used by Docker for mac and poke around. This can be done with:

docker run --rm -v /:/vm_root --entrypoint=sh alpine -c 'ls -l /vm_root/<path in macOS>'
3
  • Can you clarify what you mean by <path in macOS>?
    – Corey Cole
    Commented Aug 15, 2019 at 21:54
  • 2
    Sure! It's a bit confusing. The paths shared with docker from the macOS host (the ones you see in Preferences/Files shared) are mounted from macOS into the linux VM running the docker daemon at the same paths as in macOS. In my example i show how to get access to the vm root filesystem to poke around by running a container that volume mounts it. The problem is that docker does not allow for good reasons to do -v /:/ so we have to mount it some where in the container so i named it /vm_root. Try docker run --rm -ti -v /:/vm_root --entrypoint=sh alpine to get a shell. Hope that helps. Commented Aug 16, 2019 at 8:10
  • So by <path in macOS> i mean some path in macOS like /Users/... etc Commented Aug 16, 2019 at 8:11
4

Someone struggling with similar issue in recent Docker releases on Mac, this helped in my case. I am using Docker version: 20.10.10 Docker Desktop: 4.2.0

In Preferences > General there is an option "Use gRPC FUSE for file sharing" which is by default checked. Uncheck that option Apply and restart.

After this for me -v option started working normally and I am able to easily share file between my Mac OS host and Docker container.

1
  • awesome, thank you! worked for me too Commented Nov 26, 2021 at 21:42
0

I'm not allowed to write comments. @dkoder 's answer is not working for Docker version: 20.10.17 Docker Desktop: 4.12.0

If you uncheck the "Use gRPC FUSE for file sharing" option and click on "Apply and restart" that option will be checked again and nothing is fixed.

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 21, 2022 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.