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.
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.
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.
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.
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.
To resolve the Mounts denied
error, you need to enable file sharing for the directory you wish to mount. Follow these steps:
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).
In the Preferences or Settings window, find the File Sharing section. This section lists all directories currently shared with Docker.
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.
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.
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.
Let Dr. Droid create custom investigation plans for your infrastructure.
Book Demo