One-liner to remove all Docker containers

docker rm -f $(docker ps -aq)

docker ps -aq will give us the list of all Docker container IDs.

Once we have the container IDs, we pass it to docker rm -f which will remove them all, even if they are running (thanks to -f).

Sajad Torkamani

Hello! My name is Sajad. I’m a software developer at Nationwide and an aspiring entrepreneur. Originally from Afghanistan, I moved to London at an early age and have been living here for the past 20 years.

This is my personal website where I blog mostly about programming with occasional thoughts on a bunch of other things. I write mainly for my own benefit as I find that writing helps clarify my otherwise very confused thoughts.

Get in touch: sajadtorkamani1@gmail.com