Error response from daemon: remove mydata: volume is in use
Fixes 'volume is in use' when removing a docker volume. Use when docker volume rm fails because a container (even stopped) references the volume. Not for network or image removal conflicts.
TL;DR: Find the container holding the volume (docker ps -a --filter volume=mydata), remove it (docker rm), then docker volume rm mydata succeeds. Stopped containers keep their volume references, so docker stop is not enough.
The error
Error response from daemon: remove mydata: volume is in use - [c3d4e5f6...]Fix it
- Find the referencing containers:
docker ps -a --filter volume=mydata Expected: one or more containers, possibly exited.
- Remove them (add -f if running and you are sure):
docker rm [container] Expected: no output.
- Remove the volume:
docker volume rm mydata Expected: prints mydata.
When this applies
docker volume rm/docker volume pruneskipping a volume- Rebuilding stateful dev environments
When this does NOT apply
- Anonymous volumes (they have hex IDs; same fix, filter by the ID)
- "No such volume" (already gone)
Versions
All Docker versions.
Why it happens
Volumes are reference-counted. Any container created with the volume, running or stopped, holds a reference until the container itself is removed. Prune only removes truly unreferenced volumes.
Edge cases
docker rm -vremoves anonymous volumes attached to the container at removal time; named volumes survive unless explicitly removed.- Compose
down -vremoves the project's named volumes; plaindownkeeps them, which is why the nextupsees old data. - A container stuck in removal holds the reference; restart the daemon to clear it.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.