Docker includes a feature that allows you to mount a folder from the host machine and use it as a shared folder. Versions of macOS Catalina 10.15 and later may encounter problems accessing a folder mounted using this feature.
Ultimately, it was determined that the macOS privacy settings had blocked access to the target folder.
This article summarizes how we were able to identify and resolve the cause of this problem.
nginx containerized in Docker to create a test web server for development. We want to make various changes to the files to be placed in it, so we put the following in the
docker-compose.yml file to mount a local folder inside the container.
version: "3" services: nginx: build: . ports: - 80:80 volumes: - ./content_home:/usr/share/nginx/html
However, when we run it, we get HTTP Status 404 Not Found and cannot access the site.
When I place the
docker-compose.yml file along with a set of related files in one folder and run them in another directory, everything works fine.
Where should we check?
The following are places to check in such cases.
- Can you see the files in
- Does the host’s
- Are the host’s
./content_homepermissions and other access rights granted read permission?
Check the container
/usr/share/nginx/html on the container.
% docker container exec testserver_nginx_1 ls /usr/share/nginx html
html folder exists because it was output as
html. So, next, check the files in the folder.
% docker container exec testserver_nginx_1 ls /usr/share/nginx/html ls: cannot open directory '/usr/share/nginx/html': Operation not permitted
Access has been denied. There is likely a problem with access rights.
Check the host
Check the folder’s existence on the host and its access rights; the confirmation is to see it in the Finder: select the folder and choose “Get Info” from the “File” menu. Then, confirm “Sharing & Permissions”.
If “everyone” and “staff” are set to “read only” and “myself” is set to “read/write,” there is no problem.
macOS privacy settings
In the macOS privacy settings, the following three folders must be given permissions for each app.
When you try to access the above folders for the first time after installing the app, the OS will display a dialog asking if you want to allow it. If you do not allow it there, you will not be able to access it.
To check, do the following.
We could not access it in our environment because the “Desktop Folder” was unchecked, as shown in the screen capture.
This time, we are working on the desktop folder.
We don’t recall precisely, but we believe we unchecked it.