[英]/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.