Erfan Tahriri Erfan Tahriri - 1 year ago 279
Linux Question

How to remove all Docker containers

I want to remove all of my docker containers at once. I tried to use $ docker rm [container_id] to do so, but it removed only one container, not all.

Is there any way to remove all docker containers using one single line of code?

Answer Source

Remove containers based on status:

docker rm -v $(docker ps --filter status=exited -q)


  • The "-v" option that will delete any volumes associated with the containers.

To clean out all containers on my development machine:

docker kill $(docker ps -qa) && docker rm -v $(docker ps -qa)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download