[英]/etc/rc* not running on Ubuntu 18.04 in Docker. Cannot start cron on boot
I can't seem to convince the cron
(or any other) service to start with my Ubuntu container.我似乎无法说服
cron
(或任何其他)服务从我的 Ubuntu 容器开始。 I'm sure I'm missing something simple.我确定我错过了一些简单的东西。
I've tried using both update-rc.d
and /etc/rc.local
but no joy.我试过同时使用
update-rc.d
和/etc/rc.local
但没有任何乐趣。
In this example Dockerfile
I'm also trying to get rsyslog
running in order to debug, with the same result- the service does not start.在此示例
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"]
When I run the container:当我运行容器时:
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 is not in the ubuntu docker images, by design根据设计,systemd 不在 ubuntu docker 映像中
This is because its role as PID 1 is effectively replaced by docker's entrypoint这是因为它作为 PID 1 的角色被 docker 的入口点有效地取代了
For more, see:有关更多信息,请参阅:
https://stackoverflow.com/a/39169889/1892116 https://stackoverflow.com/a/39169889/1892116
So the correct solution is what I thought was a hack.所以正确的解决方案是我认为的黑客。 In my
entrypoint.sh
I have:在我的
entrypoint.sh
中,我有:
service rsyslog start
service cron start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.