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

DockerBEGINNERLOWUpdated Dec 6, 2025ยท 250 views

The 'volume is in use' error occurs when Docker prevents you from removing a volume because a container (running or stopped) still references it. Stop and remove the dependent container first, or restart the Docker daemon if the reference is stale.

Quick fix

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

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

# Get just the container names for easier reading
docker ps -a --filter volume=VOLUME_NAME --format "{{.Names}}"

# Alternative: inspect the volume to see 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 just the container names for easier reading
docker ps -a --filter volume=VOLUME_NAME --format "{{.Names}}"
# Alternative: inspect the volume to see mount references
docker volume inspect VOLUME_NAME
Error response from daemon: remove myvolume: volume is in use

What this error means

The "volume is in use" error in Docker appears when you try to delete a volume using `docker volume rm` while one or more containers still hold a reference to it. Docker uses reference counting to track which containers are attached to each volume. When you create a container with a volume mount (using `-v` or `--mount`), Docker increments this counter. Even after you stop a container, the reference persists until you explicitly remove the container with `docker rm`. This is a safety mechanism, not a bug. Docker prevents accidental data loss by ensuring you don't delete a volume that a container might still need. The error message typically includes the container ID in brackets to help you identify which container is blocking the removal. Importantly, the `--force` flag on `docker volume rm` does NOT override this protection - it only prevents errors when the volume doesn't exist. You must remove the container reference to delete the volume.

Typical symptoms

  • Running `docker volume rm <volume>` returns 'volume is in use'
  • The error shows a container ID in brackets like '[abc123...]'
  • Volume cannot be deleted even after stopping all visible containers
  • `docker volume ls` shows the volume exists
  • `docker ps` shows no running containers, but `docker ps -a` reveals stopped containers
  • Docker Compose fails with volume-related errors when recreating services

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 properly cleaned up with `docker compose down`
  4. Stale reference in Docker's internal state due to race condition or crash (rare)
  5. The volume belongs to a Docker Desktop extension
  6. Multiple containers share the same volume

How to fix "Error response from daemon: remove myvolume: 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 just the container names for easier reading
docker ps -a --filter volume=VOLUME_NAME --format "{{.Names}}"

# Alternative: inspect the volume to see 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.

Note: If docker ps returns nothing but docker ps -a shows containers, those are stopped containers that still hold the reference.

2Stop running containers using the volume

If any containers are still running, stop them first:

bash
# Stop a specific container
docker stop <container_id_or_name>

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

Verify the containers are stopped:

bash
docker ps --filter volume=VOLUME_NAME

This should return an empty list if all containers using the volume are now stopped.

3Remove the dependent containers

Stopping a container is not enough - you must remove it 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 use container prune to remove all stopped containers
docker container prune

After removing the containers, 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 command to clean up properly:

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

# Stop and remove containers, networks (but not volumes)
docker compose down

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

Important: You must run this command from the directory containing your docker-compose.yml file, or specify the file with -f.

This is the cleanest way to remove Compose-managed volumes because it handles all the dependencies automatically.

5Restart the Docker daemon (for stale references)

In rare cases, Docker's internal reference counter may be out of sync due to a crash or race condition. Restarting the daemon resets this in-memory state:

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 the daemon restarts, try removing the volume again:

bash
docker volume rm VOLUME_NAME

If this works, it confirms the issue was a stale reference rather than an actual container dependency.

6Manual removal (last resort)

If all else fails, you can manually remove the volume data. This is risky and should only be done when you're certain no containers need the 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 its volume list
sudo systemctl restart docker

Warning: This bypasses Docker's safety checks. Only use this when:
- You've verified no containers need this volume
- The volume contains no important data
- Other methods have failed

Advanced notes

### Understanding Docker Volume Reference Counting

Docker tracks volume usage through reference counting in memory. Each time a container is created with a volume mount, the counter increments. When a container is removed (not just stopped), the counter decrements. A volume can only be deleted when its reference count reaches zero.

This is why the --force flag doesn't help - it's designed to prevent errors when the volume doesn't exist, not to override the reference count protection.

### Named vs Anonymous Volumes

Docker handles named and anonymous volumes differently:

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

Anonymous volumes are easier to clean up with docker volume prune, but named volumes require explicit removal.

### Docker Desktop Extensions

If the volume belongs to a Docker Desktop extension, you may need to uninstall the extension through Docker Desktop's UI before the volume can be removed. Check Docker Desktop > Extensions to see installed extensions and their associated volumes.

### Cleaning Up Multiple Volumes

For bulk cleanup of unused volumes:

bash
# Remove all unused volumes (those not referenced by any container)
docker volume prune

# Add -f to skip the confirmation prompt
docker volume prune -f

# Remove everything unused (containers, images, networks, volumes)
docker system prune --volumes

### Volume Mounts in CI/CD

In CI/CD pipelines, stale volumes can accumulate. Consider adding cleanup to your pipeline:

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

# ... run your pipeline ...

# End of pipeline - cleanup
docker compose down -v

### Investigating Volume Contents

Before deleting a volume, you might want to inspect its contents:

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

# Inside the container, explore /data
ls -la /data

This lets you verify the volume is safe to delete or back up important data first.

Frequently asked questions

What does "Error response from daemon: remove myvolume: volume is in use" mean?
The "volume is in use" error in Docker appears when you try to delete a volume using docker volume rm while one or more containers still hold a reference to it. Docker uses reference counting to track which containers are attached to each volume. When you create a container with a volume mount (using -v or --mount), Docker increments this counter.
How do I fix "Error response from daemon: remove myvolume: volume is in use"?
The 'volume is in use' error occurs when Docker prevents you from removing a volume because a container (running or stopped) still references it. Stop and remove the dependent container first, or restart the Docker daemon if the reference is stale.
What causes "Error response from daemon: remove myvolume: 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 properly cleaned up with docker compose down
Is the "Error response from daemon: remove myvolume: 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