Docker命令-top

命令

docker top

描述

Display the running processes of a container
显示容器的运行进程

用法

1
docker top CONTAINER [ps OPTIONS]

选项

注意

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 通过exec执行的ps命令显示的进程信息
$ docker exec -it nginx ps aux
PID USER TIME COMMAND
1 root 0:00 nginx: master process nginx -g daemon off;
23 nginx 0:00 nginx: worker process
24 nginx 0:00 nginx: worker process
30 root 0:00 ps aux
# 通过exec查看的PID是容器内部的PID,而top命令显示的是本机的真实PID,如下
$ docker top nginx
UID PID PPID C STIME TTY TIME CMD
root 50643 50626 0 22:50 pts/0 00:00:00 nginx: master process nginx -g daemon off;
101 50684 50643 0 22:50 pts/0 00:00:00 nginx: worker process
101 50685 50643 0 22:50 pts/0 00:00:00 nginx: worker process
$ ps aux |grep nginx
root 50643 0.0 0.1 5992 2724 pts/0 Ss+ 22:50 0:00 nginx: master process nginx -g daemon off;
101 50684 0.0 0.0 6448 1672 pts/0 S+ 22:50 0:00 nginx: worker process
101 50685 0.0 0.0 6448 1448 pts/0 S+ 22:50 0:00 nginx: worker process