This error occurs when Docker Desktop cannot access a host directory you're trying to mount. The path must be added to Docker's file sharing settings before it can be used as a bind mount.
Docker Desktop on macOS and Windows runs containers inside a lightweight virtual machine. For security reasons, Docker does not automatically grant containers access to all directories on your host system. Only specific directories that have been explicitly shared with Docker can be mounted into containers. When you try to mount a directory that isn't in Docker's allowed list, you'll see this error. The message "The path /host/path is not shared from the host and is not known to Docker" means the directory you specified in your `-v` or `--mount` flag hasn't been configured as a shared folder in Docker Desktop settings. By default, Docker Desktop shares common directories like `/Users`, `/Volumes`, `/private`, `/tmp`, and `/var/folders` on macOS, and your user's home directory on Windows. Paths outside these defaults require manual configuration.
First, identify the full path Docker is trying to mount. Check your docker command or docker-compose.yml:
# Check your docker run command
docker run -v /path/to/mount:/container/path myimage
# Or check docker-compose.yml for volume definitions
cat docker-compose.yml | grep -A 5 volumesOn macOS, if the path includes symlinks, resolve them:
realpath /path/to/your/directoryThe resolved path is what Docker actually tries to access.
Navigate to Docker Desktop's file sharing configuration:
On macOS:
1. Click the Docker whale icon in the menu bar
2. Select "Preferences..." (or "Settings...")
3. Go to Resources > File Sharing
On Windows:
1. Right-click the Docker whale icon in the system tray
2. Select "Settings"
3. Go to Resources > File Sharing
Note: On Windows with WSL2 backend, file sharing is automatic for paths inside WSL distributions. The File Sharing tab only appears in Hyper-V mode.
Add your directory (or a parent directory) to Docker's file sharing list:
1. In the File Sharing settings, click the + button
2. Browse to and select the directory you need to mount
3. Click Apply & Restart
Tips:
- Share a parent directory (like /data) rather than individual subdirectories
- Avoid sharing your entire root filesystem for security reasons
- On macOS, sharing /usr/local may require additional permissions
After applying file sharing changes, Docker Desktop will restart:
1. Wait for the Docker whale icon to stop animating
2. Verify Docker is running:
docker info3. Retry your original command:
docker run -v /your/shared/path:/container/path myimagemacOS uses symlinks in several system paths. Docker needs both the symlink and the real path shared.
For example, /var is symlinked to /private/var:
ls -la /var
# lrwxr-xr-x 1 root wheel 11 Jan 1 2020 /var -> private/varSolution: Add both paths to file sharing:
- /var/folders
- /private/var/folders
Or use the resolved path in your Docker command:
docker run -v "$(realpath /var/folders/xx/path):/container/path" myimageIf adding custom paths doesn't work or isn't possible, move your project to a default shared location:
On macOS (default shared paths):
- /Users (your home directory)
- /Volumes
- /private
- /tmp
On Windows:
- Your user profile folder (C:\Users\YourName)
Example:
# Move project to home directory
mv /custom/project ~/Projects/my-project
cd ~/Projects/my-project
docker-compose upIf you're experiencing persistent issues after a Docker Desktop update, try changing the file sharing backend:
1. Open Docker Desktop Preferences
2. Go to General
3. Find the file sharing implementation option
4. Try switching between:
- VirtioFS (faster, recommended)
- gRPC FUSE (more compatible)
- osxfs (Legacy) (older, slower but most compatible)
5. Click Apply & Restart
Some users report that switching from VirtioFS to gRPC FUSE resolves file sharing issues after updates.
If file sharing settings appear corrupted, reset them:
1. Open Docker Desktop Preferences
2. Go to Troubleshoot (or click the bug icon)
3. Click Reset to factory defaults
Warning: This removes all containers, images, volumes, and settings.
Alternatively, reset only the settings file:
On macOS:
rm ~/Library/Group\ Containers/group.com.docker/settings.jsonOn Windows:
Remove-Item "$env:APPDATA\Docker\settings.json"Then restart Docker Desktop and reconfigure file sharing.
Case sensitivity on macOS:
macOS uses a case-insensitive filesystem by default. Docker may fail to mount paths with incorrect case. For example, /Volumes works but /volumes may not.
Windows with WSL2:
When using Docker Desktop with WSL2 backend, file sharing works differently:
- Paths within WSL distributions (\\wsl$\Ubuntu\...) are automatically available
- Windows paths (C:\Users\...) are accessible via /mnt/c/Users/... inside containers
- The File Sharing settings page is hidden in WSL2 mode since it's not needed
Docker Context and Remote Hosts:
This error only affects Docker Desktop. If you're using Docker Engine on a Linux server, bind mounts work without file sharing configuration since there's no VM layer.
SELinux and Security (Linux Docker Engine):
On Linux with SELinux enabled, mount errors may look similar but have a different cause. Use the :z or :Z suffix:
docker run -v /host/path:/container/path:z myimagePerformance Considerations:
Shared directories have performance overhead due to the virtualization layer. For large projects with many files, consider:
- Using named volumes instead of bind mounts for dependencies (node_modules, vendor)
- Enabling experimental file caching options in Docker Desktop
- Keeping frequently-accessed files in default shared paths
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker
Error response from daemon: failed to create the ipvlan port
How to fix 'failed to create the ipvlan port' in Docker
toomanyrequests: Rate exceeded for anonymous users
How to fix 'Rate exceeded for anonymous users' in Docker Hub