In this guide, we will talk about checking the current state of the containers in Docker.
How to Check Docker Container Status?
As we described above, if the running process changes or is terminated, then the state of the containers also changes. To view the container’s current status, users need to list them. Listing containers is an important task if the users are working with containerized applications. This process enables them to display essential information, such as container ID, image, and command utilized while building the container, current status of the container, used port for execution, creation time, and its name.
Docker allows developers to view the status of:
- All Container Status in Docker
- Only Running Containers in Docker
- Recently Created Containers in Docker
Let’s move ahead and check the practical demonstration for a better understanding!
How to View the Status of All Containers in Docker?
To check the state of all the running, paused, restraining, or stopped containers in Docker, the below-provided command is used:
Here, the -a option denotes to all. According to the below-given output, there are two containers cocoa_con1 on running state and cocoa_con is stop respectively:
How to Check the Status of Running Containers in Docker?
If you just want to check the status of all running containers in docker, then the docker ps command is useful:
It can be seen that currently only one container is running:
How to Check the Status of Recently Created Containers in Docker?
Sometimes, you need to check the current state of the recently created container for verification, whether it has been generated successfully or not. For this corresponding purpose, the docker ps -l command is used:
According to the following output, the cocoa_con1 is running:
That’s all about checking the status of the containers in Docker.
Conclusion
In Docker, users can check the current state of the containers with the help of multiple commands according to their requirements, such as the docker ps command to check the current status of all existing containers, the docker ps -a command for all running containers, and docker ps -l command for most recently created containers. This guide demonstrated the multiple commands to check the status of the containers.