Mounts denied. The paths ... are not shared from OS X and are not known to Docker

Viewed 142382

The command docker run -v /var/folders/zz/... produces the following error.

docker: Error response from daemon: Mounts denied: 
The paths /var/folders/zz/... and /var/folders/zz/...
are not shared from OS X and are not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.

When I do open File Sharing, I see that /private is listed already.

If I attempt to add /var/folder/, it resolves to /private/var/folders, which is a subset of /private and hence the addition is rejected.

To summarize, it looks to me like the directory /var/folders/.. is shared by OS X as a subdirectory of /private and hence must be known to Docker. Any help on resolving this would be appreciated.

As an experiment, I replaced the /private in File Sharing with /private/var/folders and restarted the docker but the result did not change.

Just for a more complete reference, this is the .sh script, which runs this python script, which in turn runs the docker command.

16 Answers

With the new version 3.0.0 of Docker for mac, you need to disable use gRPC FUSE for file sharing in Preferences>Experimental Features.

I had a similar problem where I had created a directory /var/tmp in my Mac which I wanted to mount in my docker container.

Solved it by adding the directory path to a file as follows:

$ cat ~/Library/Group\ Containers/group.com.docker/settings.json  
{
  "filesharingDirectories" : [
    "\/Users",
    "\/Volumes",
    "\/private",
    "\/tmp",
    "\/var\/tmp"
  ],
…

Now I could see the directory /var/tmp in Docker->preference->resources->file sharing. Then I restarted the docker.

It then solved my mounting problem.

Pre-req : need to have 'docker desktop' installed, Follow steps mentioned in image: enter image description here

As an alternative solution:

Change the path from /private/instance1-data:/home to ./instance1-data:/home

In the *nix land and hence, Docker, the . indicates the current directory. Since macOS is picky ang getting even pickier about sandboxing, this seems like a viable solution for macOS. Just create the folder needed for instance1 in the same directory.

Another advantage of this solution is that it removes the need to run docker-compose with sudo. Regardless, it causes no harm in this case but still, that's a plus.

In the current latest version ( Docker 3.0.2 ), in macos, you must allowed directory for read docker:

enter image description here

if you can't see a folder on mac unhide hiden by opening terminal and type:

defaults write com.apple.Finder AppleShowAllFiles YES

then relaunch finder by holding alt and right clicking (two finger) on the finder and select relaunch then click on "finder" next to file in the menu bar, click preferences add a check in the hard disks under show these items on the desktop then side bar check the hard disks there too then go to the hidden folder and drag it to your favorites and it will show up in the docker> preferences > resources > file sharing > + window

My issue fixed when I removed the project Path from File Sharing in docker preferences and restart the docker, Then add the project file path again.

you have to add both /private/var/tmp and /var/tmp to resolve issue

If you're still having this issue on MAC try adding: $PWD

Add $PWD before your local file directory path like so: docker run -v $PWD/folders/:/path/to/directory.

From my side: After adding the folder, restarting both terminal and docker resolved the issue on my side

I add the folder /builds to filesharingDirectories in ~/Library/Group\ Containers/group.com.docker/settings.json, like:

"filesharingDirectories": [
    "/builds",
    "/host_mnt",
    "/tmp",
    "/Users",
    "/Volumes",
    "/private",
    "/var/folders"
  ],

(I also added host_mnt)

Then I added both folders to the / using the file /etc/synthetic.conf:

mkdir -p /Users/me/gitlab-misc/builds
mkdir -p /Users/me/gitlab-misc/host_mnt
sudo vim /etc/synthetic.conf

Inside the /etc/synthetic.conf I have:

builds  /Users/me/gitlab-misc/builds
host_mnt    /Users/me/gitlab-misc/host_mnt

(Use TAB, not space)

sudo chmod 0644 /etc/synthetic.conf
sudo chown root:wheel /etc/synthetic.conf

And reboot the machine

I would like to add that I had the path already added to Docker, but I fat fingered the bind mount to be absolute instead of relative and I was pointing it to a non-existent file. I was getting the same error as OP.

For netcoreapp ensure you have shared /usr/local/share/

Related