How to Remove All Docker Containers in a Single Command

DevOps Docker

Removing All Stopped Docker Containers

To remove all the stopped docker containers in a single command, run the following command:

$ sudo docker rm $(sudo docker ps -qf 'status=exited')

Removing All Running Docker Containers

To remove all the running docker containers in a single command, run the following command:

$ sudo docker rm $(sudo docker ps -q)

Removing All Running and Stopped Docker Containers

To remove all the running and stopped docker containers in a single command, run the following command:

$ sudo docker rm $(sudo docker ps -qa)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *