吹嘘phusion/baseimage
用轻量级初始化进程解决了 pid 1 问题。如何正确使用 phusion/baseimage?我尝试使用命令ps aux
显示ps
以 PID 1 运行来调用图像。
我做错了什么?使用图像的正确方法是什么?
me@host:~/app1$ docker run --rm phusion/baseimage ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 3.0 0.0 29180 1404 ? Rs 01:27 0:00 ps aux
答案1
docker 有一个选项--init
。启动init系统蒂尼作为PID 1。
tini
存储/usr/bin/docker-init
在主机上。不幸的是,一些系统(例如 fedora 和 openSUSE)虽然--init
显示在docker run --help
.
您可以tini
自己添加到 docker 映像并使用
ENTRYPOINT /tini --
.看蒂尼自述文件。
有关失踪的更多信息,/usr/bin/docker-init
请访问:https://github.com/mviereck/x11docker/issues/23#issuecomment-386817295
答案2
我想通了 (从这里)使用的正确方法phusion/baseimage
是将其运行为 -
docker run --rm -t -i phusion/baseimage /sbin/my_init ps aux`
my_init
作为 PID1 执行并生成my_init
一个进程ps aux
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
May 8 04:18:23 daf3cfab8573 syslog-ng[10]: syslog-ng starting up; version='3.5.6'
May 8 04:18:23 daf3cfab8573 syslog-ng[10]: WARNING: you are using the pipe driver, underlying file is not a FIFO, it should be used by file(); filename='/dev/stdout'
May 8 04:18:24 daf3cfab8573 syslog-ng[10]: EOF on control channel, closing connection;
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 16
*** Running ps aux...
May 8 04:18:24 daf3cfab8573 cron[20]: (CRON) INFO (pidfile fd = 3)
May 8 04:18:24 daf3cfab8573 cron[20]: (CRON) INFO (Running @reboot jobs)
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 5.0 0.0 32304 10796 ? Ss+ 04:18 0:00 /usr/bin/python3 -u /sbin/my_init ps aux
root 10 1.0 0.0 72364 7552 ? S 04:18 0:00 /usr/sbin/syslog-ng --pidfile /var/run/syslog-ng.pid -F --no-caps
root 16 0.0 0.0 4392 1124 ? S+ 04:18 0:00 /usr/bin/runsvdir -P /etc/service
root 17 0.0 0.0 37656 3340 ? R+ 04:18 0:00 ps aux
root 18 0.0 0.0 4240 672 ? Ss 04:18 0:00 runsv cron
root 19 0.0 0.0 4240 800 ? Ss 04:18 0:00 runsv sshd
root 20 0.0 0.0 29272 2840 ? S 04:18 0:00 /usr/sbin/cron -f
*** ps exited with status 0.
*** Shutting down runit daemon (PID 16)...
*** Running /etc/my_init.post_shutdown.d/10_syslog-ng.shutdown...
May 8 04:18:24 daf3cfab8573 syslog-ng[10]: syslog-ng shutting down; version='3.5.6'
May 8 04:18:24 daf3cfab8573 syslog-ng[10]: EOF on control channel, closing connection;
*** Killing all processes...