This error occurs when Docker cannot mount a volume because the specified source path on the host machine does not exist. This commonly happens with bind mounts when the host directory has not been created, the path contains typos, or relative paths are used instead of absolute paths.
When you create a container with a volume mount, Docker needs to map a directory from your host machine to a directory inside the container. This error indicates that Docker looked for the source directory on your host but could not find it. The behavior differs depending on the mount syntax you use: - With `--mount` (recommended): Docker will fail immediately with this error if the source path does not exist, alerting you to the problem before the container starts. - With `-v` or `--volume` (legacy): Docker will silently create the missing directory as an empty folder owned by root, which often leads to confusing permission issues or missing files inside the container. Docker officially recommends using `--mount` because it provides clearer error messages and more predictable behavior.
First, check if the source path actually exists on your host machine:
ls -la /path/to/your/volumeIf the directory does not exist, create it:
mkdir -p /path/to/your/volumeThe -p flag creates any missing parent directories.
Docker requires absolute paths for bind mounts. Replace relative paths with absolute paths:
# Wrong - relative path
volumes:
- ./data:/app/data
# Correct - absolute path
volumes:
- /home/user/project/data:/app/dataAlternatively, use the $PWD environment variable:
volumes:
- ${PWD}/data:/app/dataOr in the command line:
docker run -v $(pwd)/data:/app/data myimageEnsure Docker can access the directory by setting appropriate permissions:
# Check current permissions
ls -la /path/to/your/volume
# Fix ownership if needed
sudo chown -R $USER:$USER /path/to/your/volume
# Set read/execute permissions
sudo chmod -R 755 /path/to/your/volumeNote: The user running Docker needs at least read and execute permissions on all parent directories in the path.
If your path contains symlinks, Docker may fail to resolve them. Use the real path instead:
# Find the real path
readlink -f /path/to/your/symlinked/volume
# Use the resolved path in your Docker command
docker run -v /actual/real/path:/app/data myimageThis is a known issue in Docker that has persisted across versions.
If the error persists after a volume directory was deleted, remove the orphaned Docker volume:
# List all volumes
docker volume ls
# Remove the specific volume
docker volume rm <volume_name>
# Or prune all unused volumes
docker volume pruneAfter pruning, recreate your container and the volumes will be reinitialized.
On Docker Desktop, volume mount issues can sometimes be resolved by restarting:
1. Click the Docker icon in your system tray
2. Select "Restart"
3. Wait for Docker to fully restart
4. Try running your container again
If problems persist, try switching the file sharing backend:
- Open Docker Desktop Settings
- Go to "General" or "Resources > File sharing"
- Try switching between VirtioFS and gRPC FUSE (macOS)
- Ensure your project directory is in a shared location
Docker Desktop Virtual Machine Limitations
On macOS and Windows, Docker runs inside a Linux virtual machine. By default, only certain directories are shared between your host and this VM:
- macOS: /Users, /Volumes, /private, /tmp
- Windows: Typically C:\Users
If your project is outside these directories, add it to Docker Desktop's file sharing settings.
WSL2 Volume Paths
When using Docker with WSL2 on Windows, volume paths need special handling:
- Access Windows files via /mnt/c/Users/...
- For better performance, keep project files inside the WSL filesystem at ~/projects/...
- Docker volumes are stored at: /mnt/wsl/docker-desktop-data/data/docker/volumes
Using Named Volumes vs Bind Mounts
If you do not need to access files from the host, consider using named volumes instead of bind mounts:
volumes:
mydata:
services:
app:
volumes:
- mydata:/app/dataNamed volumes are managed by Docker, automatically created, and do not have path existence issues.
Debugging with docker inspect
Use docker inspect to verify volume mounts on a running container:
docker inspect <container_id> --format '{{json .Mounts}}' | jqimage 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