【发布时间】:2020-02-07 01:55:37
【问题描述】:
我正在尝试构建一个运行 R 和 cron 的 docker 容器。我需要的是让 cron 在我启动容器时自动运行。
我的 dockerfile 如下:
# Install R version 3.6
FROM r-base:3.6.0
#install crontab
RUN apt-get update && apt-get -y install cron
# also tried CMD /etc/init.d/cron start
CMD cron
然后我构建了映像并在 bash 中运行容器。 我检查了 cron 的状态:
/etc/init.d/cron status
我得到了如下的 cron 状态:
[FAIL] cron is not running ... failed!
我可以通过手动启动 cron 来启动 cron:
/etc/init.d/cron start
我的问题是我应该如何修改我的dockerfile(CMD行),以便当docker容器启动时,cron自动启动?
提前非常感谢。
【问题讨论】:
-
当您尝试
CMD /etc/init.d/cron start时会发生什么? -
与 CMD cron 相同。当我进入 bash 中的容器并检查状态时。 cron 没有运行。