Docker Engine Docker: Error response from daemon: Mounts denied

File sharing is not enabled for the specified path on macOS or Windows.

Understanding Docker Engine

Docker Engine is a containerization technology that allows developers to automate the deployment of applications inside lightweight, portable containers. It is widely used for developing, shipping, and running applications in a consistent environment across different platforms.

Identifying the Symptom

When using Docker on macOS or Windows, you might encounter the error message: Docker: Error response from daemon: Mounts denied. This error typically occurs when trying to mount a host directory into a Docker container.

What You Observe

Upon attempting to run a Docker container with a volume mount, the operation fails, and the error message is displayed in the terminal or command prompt.

Explaining the Issue

The error Mounts denied is a common issue on macOS and Windows systems using Docker Desktop. It occurs because Docker Desktop requires explicit permission to share directories between the host and the container. If the directory you are trying to mount is not shared, Docker cannot access it, resulting in the error.

Why This Happens

Docker Desktop uses a virtual machine to run containers on macOS and Windows. For security reasons, only specified directories are accessible to Docker containers. If a directory is not shared, Docker cannot mount it, leading to the error.

Steps to Fix the Issue

To resolve the Mounts denied error, you need to enable file sharing for the directory you wish to mount. Follow these steps:

Step 1: Open Docker Desktop Preferences

Launch Docker Desktop on your macOS or Windows machine. Click on the Docker icon in the system tray and select Preferences (on macOS) or Settings (on Windows).

Step 2: Navigate to File Sharing

In the Preferences or Settings window, find the File Sharing section. This section lists all directories currently shared with Docker.

Step 3: Add the Directory

Click the + button to add a new directory. Browse to the directory you want to share and select it. Ensure the directory path is correct and click Apply & Restart to save the changes.

Step 4: Verify the Fix

After Docker Desktop restarts, try running your Docker container again with the volume mount. The error should no longer occur if the directory is correctly shared.

Additional Resources

For more information on Docker Desktop file sharing, you can refer to the official Docker documentation on macOS and Windows. These resources provide detailed guidance on configuring file sharing and troubleshooting related issues.

Never debug

Docker Engine

manually again

Let Dr. Droid create custom investigation plans for your infrastructure.

Book Demo
Automate Debugging for
Docker Engine
See how Dr. Droid creates investigation plans for your infrastructure.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid