What happens to data when you run `docker compose down` vs `down -v`?
BeginnerScenarioVolumes, storage and data
Answer
Situation read → Common accident.
What I'd do → docker compose down removes containers and networks but keeps named volumes. docker compose down -v also deletes named volumes declared in the file, and anonymous ones. Use stop if you only want to pause.
Why → -v is destructive; bind mounts are never deleted.
Interview tip → Say you guard prod hosts with backups and never run -v there.
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