See the list of Docker containers. Today I will show you, how you can check the list of all containers. There are different commands to check the containers list. Because every container has multiple status like Running, Stopped etc. So based on their status we will be checking the complete list of containers.
All the command to check list are very much similar. Due to which, it is very easy to learn, remember and execute all the commands. So let get started now to check all list of docker container.
There are multiple command to check the container which are only in running state. As the time passes every thing got the updated version. In that way docker also got updated and added new commands for containers as shown below. The below command will help you to check all the running containers.
sudo docker container ls
sudo docker ps
There are multiple command to check the stopped containers list. Below command will help you to get that containers list. You can use any command from the Old and New commands. Both the command will help you to provide the same results container list.
sudo docker container ls -a
sudo docker ps -a
Exited containers are those containers. When you came outside the container. Then that container will be known as exited container. But the drawback of exited containers are that can not start it again.
You can get the complete list of docker container by using the command. The command for getting the exited containers list is exactly similar to the stopped containers list.
There are also two ways of getting these exited containers list. We have below the commands old and the new. You can use anyone of them. Both command will help you to get your all exited containers list.
sudo docker container ls -a -f status=exited
sudo docker ps -a -f status=exited
If you do not see any exited container in your list after using this exited command. Then this not an issue. And you do not need to worry about it. Because it simply means that there are not any exited container available on your machine.
Before you are going to get the complete list of docker containers. You must have created some container. Because if you don’t have any container. Then you can’t see any containers list.
So first create the container. And for creating container you must have some docker images in your machine. If you don’t have docker image. Then you can get it from docker hub or can create your own image with the help of dockerfile.
When you have docker image. Then for to create container you will have to run the docker image. And after that your docker container will be created. So for running the docker image there a command. You can see that run command below.
sudo docker run -d -it <image-name>
In this way you will get a new container in your machine. Which can be use to develop and deploy the application.
You can see the all docker commands at one page. And you can also download those all docker commands from this page which are absolutely Free.
In the conclusion, you have seen the way. how to check the list of docker containers. Running container list and stopped container list. After that you have also seen how you can create a docker container from a docker image.
I hope this article was very helpful to you for having a clear understanding of containers list and all the prerequisites.
So thank you very much for reading this article.