How to fix Error response from daemon: remove volume: volume is in use in Docker

DockerBEGINNERLOWUpdated Dec 6, 2025ยท 229 views

The 'remove volume: volume is in use' error occurs when you try to delete a Docker volume that is still referenced by a container. Remove or stop the dependent container first, then delete the volume.

Quick fix

Fixes Error response from daemon: remove volume: volume is in use

# List all containers (including stopped) using this volume
docker ps -a --filter volume=VOLUME_NAME

# Get container names only
docker ps -a --filter volume=VOLUME_NAME --format "{{.Names}}"

# Inspect the volume for mount references
docker volume inspect VOLUME_NAME
  1. Find containers using the volume
  2. Stop running containers using the volume
  3. Remove the dependent containers
  4. Use Docker Compose down for Compose projects
docker โ€” error
# List all containers (including stopped) using this volume
docker ps -a --filter volume=VOLUME_NAME
# Get container names only
docker ps -a --filter volume=VOLUME_NAME --format "{{.Names}}"
# Inspect the volume for mount references
docker volume inspect VOLUME_NAME
Error response from daemon: remove volume: volume is in use

What this error means

The "remove volume: volume is in use" error appears when you attempt to delete a Docker volume using `docker volume rm` while a container still holds a reference to it. Docker maintains an internal reference count for each volume. When you create a container with a volume mount (via `-v`, `--mount`, or Docker Compose), Docker increments this counter. Even after stopping a container, the reference persists until the container is explicitly removed with `docker rm`. This is a safety feature, not a bug. Docker prevents accidental deletion of volumes that containers might still need. The error message typically includes the container ID to help you identify which container is blocking the removal. Note that the `--force` flag on `docker volume rm` does not override this protection. It only suppresses errors when the volume doesn't exist. You must first remove the container to release the volume reference.

Typical symptoms

  • Running `docker volume rm <volume>` fails with 'volume is in use' error
  • The error message shows 'Error response from daemon: remove volume: volume is in use'
  • Volume cannot be deleted even when no containers appear to be running
  • `docker volume ls` confirms the volume exists
  • `docker ps` shows no running containers, but stopped containers exist
  • Docker Compose projects fail to recreate with volume conflicts

Common causes

  1. A stopped container is still referencing the volume (most common)
  2. A running container is actively using the volume
  3. Docker Compose created containers that weren't cleaned up with `docker compose down -v`
  4. Multiple containers share the same volume
  5. Stale reference in Docker's internal state after a crash or race condition (rare)
  6. The volume is used by a Docker Desktop extension or plugin

How to fix "Error response from daemon: remove volume: volume is in use"

1Find containers using the volume

First, identify which containers are referencing the volume:

bash
# List all containers (including stopped) using this volume
docker ps -a --filter volume=VOLUME_NAME

# Get container names only
docker ps -a --filter volume=VOLUME_NAME --format "{{.Names}}"

# Inspect the volume for mount references
docker volume inspect VOLUME_NAME

Replace VOLUME_NAME with your actual volume name. The --filter volume= flag shows only containers that have this volume mounted.

Tip: If docker ps returns nothing but docker ps -a shows containers, those are stopped containers still holding the reference.

2Stop running containers using the volume

If containers are still running, stop them first:

bash
# Stop a specific container
docker stop <container_id_or_name>

# Stop all containers using the volume
docker stop $(docker ps -q --filter volume=VOLUME_NAME)

Verify containers are stopped:

bash
docker ps --filter volume=VOLUME_NAME

This should return an empty list.

3Remove the dependent containers

Stopping is not enough - remove the containers to release the volume reference:

bash
# Remove a specific container
docker rm <container_id_or_name>

# Remove all containers using the volume
docker rm $(docker ps -a -q --filter volume=VOLUME_NAME)

# Or prune all stopped containers
docker container prune

Now try deleting the volume again:

bash
docker volume rm VOLUME_NAME
4Use Docker Compose down for Compose projects

If the volume was created by Docker Compose, use the compose commands:

bash
# Navigate to your docker-compose.yml directory
cd /path/to/your/project

# Stop and remove containers (keeps volumes)
docker compose down

# Stop and remove containers AND volumes
docker compose down --volumes
# or the shorthand
docker compose down -v

Important: Run this from the directory containing your docker-compose.yml or specify the file with -f.

This is the cleanest way to remove Compose-managed volumes.

5Restart the Docker daemon for stale references

In rare cases, Docker's reference counter may be out of sync. Restart the daemon:

bash
# Linux (systemd)
sudo systemctl restart docker

# Linux (service)
sudo service docker restart

# macOS / Windows
# Restart Docker Desktop from the system tray/menu bar

After restart, try removing the volume:

bash
docker volume rm VOLUME_NAME
6Manual removal as a last resort

If all else fails, manually remove the volume data:

bash
# Find the volume's physical location
docker volume inspect --format '{{ .Mountpoint }}' VOLUME_NAME

# Manually remove the volume directory (Linux only)
sudo rm -rf /var/lib/docker/volumes/VOLUME_NAME

# Restart Docker to refresh the volume list
sudo systemctl restart docker

Warning: This bypasses Docker's safety checks. Only use when:
- No containers need this volume
- The volume contains no important data
- All other methods have failed

Advanced notes

### How Docker Volume Reference Counting Works

Docker tracks volume usage through in-memory reference counting. Each container creation with a volume mount increments the counter. Container removal (not just stopping) decrements it. A volume can only be deleted when the count reaches zero.

The --force flag on docker volume rm doesn't override this - it's designed to suppress "volume not found" errors, not bypass reference protection.

### Named vs Anonymous Volumes

| Type | Created By | Naming | Cleanup Method |
|------|-----------|--------|----------------|
| Named | docker volume create or compose volumes: | User-specified | Manual docker volume rm |
| Anonymous | -v /path without name | Random hash | docker volume prune |

Anonymous volumes can be cleaned with docker volume prune, but named volumes require explicit removal.

### Bulk Volume Cleanup

For removing multiple unused volumes:

bash
# Remove all unused volumes
docker volume prune

# Skip confirmation prompt
docker volume prune -f

# Nuclear option: remove everything unused
docker system prune --volumes

### CI/CD Pipeline Considerations

Stale volumes can accumulate in CI environments. Add cleanup to your pipeline:

bash
# Start of pipeline
docker compose down -v 2>/dev/null || true
docker volume prune -f

# ... pipeline steps ...

# End of pipeline
docker compose down -v

### Inspecting Volume Contents Before Deletion

Check volume contents before deleting:

bash
# Create a temporary container to explore
docker run -it --rm -v VOLUME_NAME:/data alpine sh

# Inside the container
ls -la /data

Frequently asked questions

What does "Error response from daemon: remove volume: volume is in use" mean?
The "remove volume: volume is in use" error appears when you attempt to delete a Docker volume using docker volume rm while a container still holds a reference to it. Docker maintains an internal reference count for each volume. When you create a container with a volume mount (via -v, --mount, or Docker Compose), Docker increments this counter.
How do I fix "Error response from daemon: remove volume: volume is in use"?
The 'remove volume: volume is in use' error occurs when you try to delete a Docker volume that is still referenced by a container. Remove or stop the dependent container first, then delete the volume.
What causes "Error response from daemon: remove volume: volume is in use"?
A stopped container is still referencing the volume (most common) A running container is actively using the volume Docker Compose created containers that weren't cleaned up with docker compose down -v
Is the "Error response from daemon: remove volume: volume is in use" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading