1. 通过docker inspect进行查找
[root@k8s-master ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
92ff5da5ed02 mysql “docker-entrypoint.s…” 10 days ago Up 10 days
[root@k8s-master ~]# docker inspect -f ‘{{.State.Pid}}’ 92ff5da5ed02
27856
2. 使用docker container top进行查看
[root@k8s-master ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
92ff5da5ed02 mysql “docker-entrypoint.s…” 10 days ago Up 10 days
[root@k8s-master ~]# docker container top 92ff5da5ed02
UID PID PPID C
polkitd 27856 27815 0
容器的PID是27856,PPID是它的父进程。