本文共 2857 字,大约阅读时间需要 9 分钟。
[root@localhost ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES74e5b4373374 digoal/sshd:latest "/usr/sbin/sshd -D" 29 minutes ago Up 29 minutes 22/tcp digoalcontainer对应的IP和PID如下 :
[root@localhost ~]# docker inspect digoal "IPAddress": "172.17.0.22", "Pid": 8378,登录到container, 并启动一个postgresql server, 便于查看进程结构.
[root@localhost ~]# ssh 172.17.0.22root@172.17.0.22's password: Last login: Thu Nov 27 13:32:37 2014 from 172.17.42.1在container内部, pid=1的进程是docker 的entrypoint或cmd执行的命令, 例如sshd的镜像执行的是sshd -D.
[root@74e5b4373374 ~]# ps -ewf|grep 1root 1 0 0 13:32 ? 00:00:00 /usr/sbin/sshd -D
[root@74e5b4373374 ~]# ps -ewfjH|grep postgrespostgres 288 1 285 8 0 13:35 ? 00:00:00 /usr/bin/postgrespostgres 289 288 289 289 0 13:35 ? 00:00:00 postgres: logger process postgres 291 288 291 291 0 13:35 ? 00:00:00 postgres: checkpointer process postgres 292 288 292 292 0 13:35 ? 00:00:00 postgres: writer process postgres 293 288 293 293 0 13:35 ? 00:00:00 postgres: wal writer process postgres 294 288 294 294 0 13:35 ? 00:00:00 postgres: autovacuum launcher process postgres 295 288 295 295 0 13:35 ? 00:00:00 postgres: stats collector process在宿主机上看的话, container继承自docker server, container中的其他进程继承自container cmd或entrypoint调用.
# ps -ewfjH|grep postgresroot 4661 1 4661 4661 1 19:23 ? 00:02:14 /usr/bin/docker -d --selinux-enabled=false -g /data01/dockerroot 8378 4661 8378 8378 0 21:32 ? 00:00:00 /usr/sbin/sshd -D26 8840 8378 8837 8458 0 21:35 ? 00:00:00 /usr/bin/postgres26 8841 8840 8841 8841 0 21:35 ? 00:00:00 postgres: logger process 26 8843 8840 8843 8843 0 21:35 ? 00:00:00 postgres: checkpointer process 26 8844 8840 8844 8844 0 21:35 ? 00:00:00 postgres: writer process 26 8845 8840 8845 8845 0 21:35 ? 00:00:00 postgres: wal writer process 26 8846 8840 8846 8846 0 21:35 ? 00:00:00 postgres: autovacuum launcher process 26 8847 8840 8847 8847 0 21:35 ? 00:00:00 postgres: stats collector processPID=1的进程是systemd(CentOS 7.x 是这样的)
root 1 0 0 19:03 ? 00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 23如果CentOS 6.x 是init进程 :
root 1 0 0 Nov20 ? 00:00:02 /sbin/init
转载地址:http://rhbxa.baihongyu.com/