In this write-up, we will talk about showing processes running in a Docker container.
How do I list Processes Running in a Docker Container?
Different commands are used for listing the currently running processes in a container, such as:
Using “docker inspect”
To list the running process of Docker containers, first get the list of currently running containers by executing the below-provided command:
According to the below-given output, thirsty_meitner container is running:
Now, run the docker inspect command to list the Docker container’s running processes:
Here, the comprehensive detail of the container along with its running processes has been listed successfully:
Using “docker top”
Another easiest way to display the processes running in Docker containers is by executing the docker top command. It shows processes in real-time and helps users diagnose as well as debug problems. As follows:
As you can see, the information about the running processes has been displayed along with their user ID (UID), process ID (PID), CPU usage, and many more:
Using “docker exec”
The docker exec command is also used for listing the running processes in a Docker container along with the ps command. Along with this command, you can use multiple arguments and options for more detail. For instance, use the provided command along with the -aux option for showing the running processes of a container as well as user ID, process ID, CPU usage, memory usage, the process starting time, command, and many more:
That’s all about listing processes running in a Docker Container.
Conclusion
Multiple commands are used for listing the processes running in Docker containers, such as the “docker inspect” command to display the comprehensive detail of the container and its running process, the “docker top” command, and the “docker exec” command for showing the running processes including the user ID, process ID, CPU usage, memory usage, the process starting time, and command. This guide illustrated the multiple commands for listing processes running in a Docker container.