[英]/etc/rc* not running on Ubuntu 18.04 in Docker. Cannot start cron on boot
我似乎无法说服cron
(或任何其他)服务从我的 Ubuntu 容器开始。 我确定我错过了一些简单的东西。
我试过同时使用update-rc.d
和/etc/rc.local
但没有任何乐趣。
在此示例Dockerfile
,我还尝试运行rsyslog
以进行调试,结果相同 - 服务未启动。
# syntax = docker/dockerfile:experimental
FROM ubuntu:18.04
RUN apt-get update && apt-get install --reinstall -y \
rsyslog
# fix for https://stackoverflow.com/questions/56609182/openthread-environment-docker-rsyslogd-imklog-cannot-open-kernel-log-proc-km
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
# run at startup
RUN update-rc.d rsyslog defaults
# ...really run at startup
RUN echo "service rsyslog start" >> /etc/rc.local
RUN apt-get update && apt-get install -y \
cron
# run at startup
RUN update-rc.d cron defaults
# ...really run at startup
RUN echo "service cron start" >> /etc/rc.local
ENTRYPOINT ["/bin/bash"]
当我运行容器时:
root@e392a9404e0f:/# service --status-all
[ - ] cron
[ ? ] hwclock.sh
[ - ] procps
[ - ] rsyslog
root@e392a9404e0f:/# service cron start
* Starting periodic command scheduler cron [ OK ]
root@e392a9404e0f:/# service --status-all
[ + ] cron
[ ? ] hwclock.sh
[ - ] procps
[ - ] rsyslog
根据设计,systemd 不在 ubuntu docker 映像中
这是因为它作为 PID 1 的角色被 docker 的入口点有效地取代了
有关更多信息,请参阅:
https://stackoverflow.com/a/39169889/1892116
所以正确的解决方案是我认为的黑客。 在我的entrypoint.sh
中,我有:
service rsyslog start
service cron start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.