Docker top command
docker top The command is used to display the running processes in a specified container.
docker top The command is similar to a command in Linux top or ps ; it helps users view process information inside a container, making it easy to monitor and debug activity within the container.
Syntax
docker top [OPTIONS] CONTAINER [ps OPTIONS]
View the processes inside a container:
docker top my_container
This displays all running processes in the container my_container.
** Using custom ps options:**
docker top my_container -o pid,comm
This displays all running processes in the container my_container, showing only the pid and comm columns.
Example
View the processes inside the container:
docker top my_container
Example output:
UID PID PPID C STIME TTY TIME CMD
root 1725 1708 0 14:02 ? 00:00:00 bash
root 1767 1725 0 14:03 ? 00:00:00 ps
Custom output:
docker top my_container -o pid,comm
Example output:
PID COMMAND
1725 bash
1767 ps
Common Scenarios
- Monitor activity inside a container: By viewing the processes inside a container, users can monitor the applications and services running inside the container.
- Debugging and troubleshooting: When a container has a problem, you can use the
docker topcommand to view the processes inside the container to help troubleshoot the problem. - Resource management: Understand the processes and resource usage inside the container, facilitating resource management and optimization.
docker top The command is a useful tool that helps users view information about the processes running inside a container. With it, users can monitor, debug, and manage activity inside the container to ensure it runs normally.
Docker Command Reference