The 'no such volume' error occurs when Docker cannot find a volume that a container references. This usually happens after a volume was deleted while a container still references it, or when using docker start on a container whose volume no longer exists. The fix involves removing the orphaned container and recreating it.
The "no such volume" error in Docker appears when you attempt to start or run a container that references a volume which no longer exists in Docker's volume registry. This error typically occurs in one of these scenarios: 1. **Orphaned container reference**: A container was created with a volume mount, but the volume was later deleted (either manually or by `docker volume prune`). The container configuration still references the old volume ID. 2. **Docker state corruption**: Docker's internal state became inconsistent, often after an abnormal shutdown, crash, or interrupted operation. The container metadata points to a volume that Docker cannot locate. 3. **Volume name mismatch**: In docker-compose, a volume name in the YAML doesn't match any existing volume, possibly due to a typo or using `docker-compose start` instead of `docker-compose up`. Docker stores volume references in container metadata. When you run `docker start` on an existing container, Docker attempts to re-attach all volumes that were configured when the container was created. If any of these volumes no longer exist, Docker fails with this error rather than starting the container in an inconsistent state.
First, confirm which container is causing the error and examine its volume configuration:
# List all containers (including stopped)
docker ps -a
# Inspect the container's volume mounts
docker inspect <container_id> --format '{{json .Mounts}}' | jq
# If you don't have jq, use plain inspect
docker inspect <container_id> | grep -A 20 "Mounts"Look for volume entries with a Name or Source that might reference a missing volume. The volume ID from the error message can help identify which mount is problematic.
Compare the volume names/IDs against existing volumes:
docker volume lsSince the container references a volume that no longer exists, you need to remove the container and recreate it:
# Remove the container (must be stopped first)
docker stop <container_id> 2>/dev/null
docker rm <container_id>If you have multiple containers with this issue:
# Remove all stopped containers (use with caution)
docker container prune
# Or remove specific containers
docker rm $(docker ps -aq -f status=exited)Important: Removing a container deletes its writable layer. Any data stored inside the container (not in volumes) will be lost.
If you need the volume, create it before starting the container:
# Create a named volume
docker volume create <volume_name>
# Verify it exists
docker volume ls | grep <volume_name>
# Inspect the new volume
docker volume inspect <volume_name>If using docker-compose, ensure your volumes are defined in the compose file:
version: '3.8'
services:
app:
image: myapp
volumes:
- mydata:/data
volumes:
mydata: # This creates the volume if it doesn't existNow recreate the container with the proper volume configuration:
# Using docker run
docker run -d --name mycontainer -v myvolume:/data myimage
# Using docker-compose (recommended)
docker-compose up -d
# For docker-compose, if you previously used 'start', use 'up' instead
# 'up' creates resources, 'start' only starts existing containers
docker-compose up -d <service_name>The key difference:
- docker-compose start - Starts existing containers (fails if volumes missing)
- docker-compose up - Creates containers and volumes if needed
If the volume actually exists but Docker can't find it, the daemon state may be corrupted. A restart can help:
# Linux (systemd)
sudo systemctl restart docker
# Linux (service)
sudo service docker restart
# macOS / Windows
# Restart Docker Desktop from the system tray/menu barAfter restarting, verify volumes are accessible:
docker volume ls
docker volume inspect <volume_name>Then try starting your container again.
This error has been associated with bugs in older Docker versions. If you're experiencing this regularly, update Docker:
# Check current version
docker version
# Ubuntu/Debian
sudo apt update && sudo apt upgrade docker-ce docker-ce-cli containerd.io
# CentOS/RHEL
sudo yum update docker-ce docker-ce-cli containerd.io
# macOS/Windows
# Update through Docker Desktop applicationKnown issues related to this error include:
- [docker/for-mac#2552](https://github.com/docker/for-mac/issues/2552) - Fixed in Docker Desktop updates
- [moby/moby#20659](https://github.com/moby/moby/issues/20659) - Volume lookup issues in older versions
### Understanding Docker Volume Lifecycle
Docker volumes exist independently of containers. When you create a container with -v myvolume:/path:
1. Docker checks if myvolume exists
2. If not, Docker creates it
3. Docker stores the volume reference in the container's configuration
4. This reference persists even when the container stops
The problem arises when you delete the volume but not the container. The container config still holds the old volume reference.
### docker start vs docker-compose up
This error commonly occurs when mixing start and up commands:
| Command | Creates Resources | Best For |
|---------|------------------|----------|
| docker start | No | Restarting existing containers |
| docker run | Yes (container only) | One-off containers |
| docker-compose start | No | Restarting compose services |
| docker-compose up | Yes (all resources) | Initial deployment & recovery |
Best practice: Use docker-compose up -d instead of docker-compose start for better resilience.
### Preventing This Error
1. Don't prune volumes carelessly:
# This removes ALL unused volumes - be careful!
docker volume prune
# Better: list unused volumes first
docker volume ls -f dangling=true2. Remove containers before volumes:
# Correct order
docker rm mycontainer
docker volume rm myvolume
# Or use compose to handle dependencies
docker-compose down --volumes3. Use named volumes in compose:
volumes:
mydata:
name: myproject_data # Explicit name prevents orphans### Volume Driver Issues
If you're using a volume driver plugin (e.g., for NFS, cloud storage), the error may indicate driver problems:
# Check volume driver
docker volume inspect <volume> --format '{{.Driver}}'
# List available drivers
docker plugin ls
# Check driver status
docker plugin inspect <driver>Ensure the driver plugin is running and properly configured.
### CI/CD Pipeline Considerations
In CI/CD environments, this error often appears when pipelines share Docker hosts:
# Defensive startup script
docker-compose down --volumes 2>/dev/null || true
docker volume prune -f
docker-compose up -d --buildThis ensures a clean state before each pipeline run.
### Recovering Data from Orphaned Volume References
If you accidentally deleted a volume but still have the container config, you might recover data from Docker's internal storage (Linux only):
# Find the container's data
ls -la /var/lib/docker/containers/<container_id>/
# Volume data location (if using local driver)
ls -la /var/lib/docker/volumes/However, if docker volume prune was used, the actual data is likely gone.
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: invalid reference format: repository name must be lowercase
How to fix 'repository name must be lowercase' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec