You need to find which container is using a volume before deleting it.
BeginnerScenarioVolumes, storage and data
Answer
Situation read → docker volume rm fails with "volume is in use".
What I'd do →
docker ps -a --filter volume=pgdata --format '{{.ID}} {{.Names}} {{.Status}}'
docker volume inspect pgdata
Stop and remove the referencing containers, then docker volume rm pgdata.
Why → Stopped containers still hold references.
Interview tip → docker volume prune removes unused volumes (anonymous only unless -a); never run it blindly in prod.
More on Volumes, storage and data
A Postgres container was removed and the data is gone. How should it have been run?BeginnerBind mount or named volume for local development of a Node app?BeginnerHow do you back up a named volume?IntermediateTwo containers must share files. What are your options?BeginnerA container needs a writable temp area but the root filesystem is read-only.IntermediateMoving a database volume from one Docker host to another.Intermediate