Check privacy settings when using Docker on macOS

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.



We have 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"
    build: .
      - 80:80
      - ./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.

  • Does /usr/share/nginx/html exist?
  • Can you see the files in /usr/share/nginx/html?
  • Does the host’s ./content_home exists?
  • Are the host’s ./content_home permissions and other access rights granted read permission?

Check the container

Check /usr/share/nginx/html on the container.

% docker container exec testserver_nginx_1 ls /usr/share/nginx

The 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.

  • Downloads
  • Documents
  • Desktop

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.

(1) Select “System Preferences…” from the Apple menu.

(2) Click the “Security & Privacy”.

(3) Open the “Privacy” tab.

(4) Select the “Files and Folders”.

Set file and folder access rights
Set file and folder access rights

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.


Authored Books

  • URLをコピーしました!
  • URLをコピーしました!


Akira Hayashi (林 晃)のアバター Akira Hayashi (林 晃) Representative(代表), Software Engineer(ソフトウェアエンジニア)

アールケー開発代表。Appleプラットフォーム向けの開発を専門としているソフトウェアエンジニア。ソフトウェアの受託開発、技術書執筆、技術指導・セミナー講師。note, Medium, LinkedIn
Representative of RK Kaihatsu. Software Engineer Specializing in Development for the Apple Platform. Specializing in contract software development, technical writing, and serving as a tech workshop lecturer. note, Medium, LinkedIn