EDIT (2/19/21): A lot of time has elapsed since I asked this original question years ago and I've seen a flurry of activity since then. I re-selected an answer which I think is consistent with the most localized and safe option for solving this issue (which is typically associated with docker-compose). While docker did introduce the prune
command, it is generally a dangerous operation and I would be cautious about using it as you may unintentionally impact other applications or setups you have on your machine
I've been having issues with removing Docker volumes with Docker 1.9.1.
I've removed all my stopped containers so that docker ps -a
returns empty.
When I use docker volume ls
, I'm given a whole host of Docker containers:
docker volume ls
DRIVER VOLUME NAME
local a94211ea91d66142886d72ec476ece477bb5d2e7e52a5d73b2f2f98f6efa6e66
local 4f673316d690ca2d41abbdc9bf980c7a3f8d67242d76562bbd44079f5f438317
local eb6ab93effc4b90a2162e6fab6eeeb65bd0e4bd8a9290e1bad503d2a47aa8a78
local 91acb0f7644aec16d23a70f63f70027899017a884dab1f33ac8c4cf0dabe5f2c
local 4932e2fbad8f7e6246af96208d45a266eae11329f1adf176955f80ca2e874f69
local 68fd38fc78a8f02364a94934e9dd3b5d10e51de5b2546e7497eb21d6a1e7b750
local 7043a9642614dd6e9ca013cdf662451d2b3df6b1dddff97211a65ccf9f4c6d47
#etc x 50
Since none of these volumes contain anything important, I try to purge all the volumes with docker volume rm $(docker volume ls -q)
.
In the process, the majority are removed, but I get back:
Error response from daemon: Conflict: volume is in use
Error response from daemon: Conflict: volume is in use
Error response from daemon: Conflict: volume is in use
Error response from daemon: Conflict: volume is in use
Error response from daemon: Conflict: volume is in use
For a sizeable portion of them. If I don't have any containers existing in the first place, how are these volumes being used?
Perhaps the volume was created via docker compose
? If so, remove it with:
docker compose down --volumes
while in the same directory as your docker-compose.yml
or docker-compose.yaml
file. Note that this will permanently delete all volumes (as well as containers/networks) defined in the configuration file.
Credit to Niels Bech Nielsen!