我似乎无法说服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