Remove all Containers Docker Having Status Running, Stopped, Exited

Today we will see, how to remove all containers docker. Before removing the containers first you must know the status of the containers. Because the containers can have different status.

Remove All Containers Docker

The status could be like Running container, Stopped container, Exited container. And for removing all these different status containers. You will be using different commands according to the container status.

All these removing commands are very much similar. Due to which this will became very easy for you to Learn, Remember and Execute the commands. Once you execute it by your own, then you will find it so easy that even a child can also execute these command.

So let’s get start to learn how to delete all containers docker.

Remove All Containers Docker

When you are going to remove a container. Then first check the status of that container. To check these commands you can follow the docker command page in the menu. After that use the appropriate command to remove that container.

Remove Running Containers

When you are removing a running container. Then its not possible to remove it directly by using rm command. So for removing the running container. Then you must have to remove it forcefully. As you can see the below commands.

sudo docker rm --force <container-id>


sudo docker rm -f <container-id>

Remove All Stopped Containers

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


sudo docker rm $(sudo docker ps -aq)

Remove All Exited Containers

sudo docker rm $(sudo docker ps -q -f status=exited)


sudo docker rm $(sudo docker ps -q -f status=exited)

When you will use these commands. Then you can easily delete all containers docker.

Prerequisites of Removing All Containers

First of all, before you remove or deleting all containers docker. First you will have to check is there any container available on your machine or not. That container could have any status like running, stopped and exited. That status does not matter.

But for removing, there must be containers available. Because if you don’t have any container available on your machine. Then there is no use of using these removing commands. You can also check list of docker container by following below link.

Remove all container docker

So if you don’t have any containers available then you first go and create a container. You can easily create a new container from the docker image run command. When you execute the docker image run command.

Then you will see automatically a new container will be created. After having a new container, then it will be possible for you to use these removing commands. For deleting this newly created docker container.

For more information on how to create container. You can follow the docker command page there you will get all the commands.

List of Docker Containers

You can check all the list of docker containers on your machine. There is detailed description on how to check all container list.

Delete All Containers Docker

Docker Commands

If you are seeing for all the docker commands cheat sheet at one place then you can follow the below link. And the best thing is that you can also download all docker commands from there easily.

Delete all container docker


In the conclusion, we have seen how to remove all containers docker. We have also seen how to remove all the different status containers. By using the appropriate command according to the status of docker containers.

When you are aware of container status then it became easy task for you to remove the container. And we have also seen the prerequisites of removing container. Because that is the foremost thing which you should do first.

After that we saw, if there is no container. Then what you have to do or what you should do for having at-least a container of any status on your machine.

I hope this article gives you a clear ideas about removing containers.

Thank you very much for reading this article.