没有-t开关的Docker中的Systemd输出

时间:2019-06-20 12:20:21

标签: shell docker systemd

当以终端模式启动Docker映像时,例如:

docker run --mount type=tmpfs,destination=/run --mount type=tmpfs,destination=/run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro --entrypoint '/bin/bash' -it jrei/systemd-debian:10

,然后手动输入:

exec /lib/systemd/systemd

systemd显示初始化日志,如:

ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
Detected virtualization docker.
Detected architecture x86-64.

Welcome to Debian GNU/Linux 10 (buster)!

Set hostname to <e9366e98a874>.
File /lib/systemd/system/systemd-journald.service:12 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
[  OK  ] Reached target Slices.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Reached target Swap.
[  OK  ] Reached target Local File Systems.
         Starting Create System Users...
[  OK  ] Reached target Local Encrypted Volumes.
[  OK  ] Reached target Paths.
....


以无终端模式启动Docker映像时,例如:

docker run --mount type=tmpfs,destination=/run --mount type=tmpfs,destination=/run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro --entrypoint '/bin/bash' jrei/systemd-debian:10 -c "exec /lib/systemd/systemd"

systemd不显示任何输出。我不能使用-t-i开关,因为docker命令在我使用的命令执行程序中是硬连线的。应该如何修改上面的命令以使用输出启动并仍然使用PID 1(直接从入口外壳通过exec来启动systemd,而没有-t Docker tty开关?

0 个答案:

没有答案