Delete All My Docker Containers

Sometimes you need a clean slate and want to completely blow away your Dockerized dev dependencies. I recently had a little trouble genuinely clearing Docker containers containing a database and a message queue which I wanted completely fresh and empty.

The following commands did the trick.

docker-compose down -v
docker system prune
docker-compose up

docker compose down stops and removes containers in the compose file. -v means “remove named volumes declared in the ‘volumes’ section of the Compose file and anonymous volumes attached to containers. This alone didn’t seem to do what I needed.

docker system prune “Remove all unused containers, networks, images (both dangling and unreferenced)”

This command may also do the trick but I haven’t had a chance to use it yet.

docker-compose down –rmi all