我正在尝试运行一个节点12.13.0阿尔卑斯码头容器,它每15分钟运行一次脚本。根据阿尔卑斯的wiki cron剖面,我应该能够在Dockerfile中添加一个运行任务,以便通过以下方式将crond作为服务运行:
rc-service crond start && rc-update add crond但是,这将返回一个错误:
rc-service: service `crond' does not exist运行单独的Docker容器只是为了对这个Docker容器运行cron任务,这是而不是的一个选项。这个容器已经非常轻量级了,不能做太多的事情。
这是我的Dockerfile:
FROM node:12.13.0-alpine
RUN apk add --no-cache tini openrc
WORKDIR /opt/app
COPY script.sh /etc/periodic/15min/
RUN chmod a+x /etc/periodic/15min/script.sh
RUN rc-service crond start && rc-update add crond
COPY . .
RUN chmod a+x startup.sh
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./startup.sh"]这里的任何帮助都将不胜感激。
发布于 2019-10-27 09:46:06
问题是一些阿尔卑斯码头集装箱没有安装busybox-initscript包。安装此程序后,crond将作为服务运行。我遇到的另一个问题是,run-parts命令执行/etc/periodic文件夹中的文件,希望没有扩展名,所以我去掉了它,现在一切都正常了。
工作的Dockerfile如下所示:
FROM node:12.13.0-alpine
RUN apk upgrade --available
RUN apk add --no-cache tini openrc busybox-initscripts
WORKDIR /opt/app
COPY runScraper /etc/periodic/15min/
RUN chmod a+x /etc/periodic/15min/runScraper
COPY . .
RUN chmod a+x startup
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./startup"]发布于 2021-07-09 16:22:52
自从上一个解决方案发布以来,阿尔卑斯可能已经改变了事情的工作方式,现在它只是报告:
# rc-service crond start
* You are attempting to run an openrc service on a
* system which openrc did not boot.
* You may be inside a chroot or you may have used
* another initialization system to boot this system.
* In this situation, you will get unpredictable results!
* If you really want to do this, issue the following command:
* touch /run/openrc/softlevel
* ERROR: syslog failed to start
* ERROR: cannot start crond as syslog would not start在自动激活它的“busybox”安装过程中无声地失败。
重要的一点是:
touch /run/openrc/softlevel这使其工作,请注意,您仍然需要安装上一个解决方案的其余部分,即"openrc“和”“。
https://stackoverflow.com/questions/58577707
复制相似问题