Docker

How to Check Docker Container Status

Docker containers are used to run the applications and multiple other processes inside it by following the Docker images that contain the set of instructions. If the current state of the running applications changes, then the execution of the container is also affected. Thus, the containers can be changed to different states throughout its lifecycle.

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:

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:

docker ps -a

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:

docker ps

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:

docker ps -l

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.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.