高山:"service `crond' does not exist"
Alpine: "service `crond' does not exist"
我正在尝试 运行 一个 Node 12.13.0 Alpine Docker 容器,该容器 运行 每 15 分钟执行一次脚本。根据 Alpine's wiki cron section,我应该可以通过以下方式将 Docker 文件中的 运行 任务添加到 运行 crond 作为服务:
rc-service crond start && rc-update add crond
然而returns这是一个错误:
rc-service: service `crond' does not exist
运行 一个单独的 Docker 容器 运行 针对此 Docker 容器的 cron 任务 不是 一个选项.这个容器已经非常轻量级了,并没有做太多事情。
这是我的Docker文件:
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"]
如有任何帮助,我们将不胜感激。
问题是一些 Alpine Docker 容器没有安装 busybox-initscripts package。安装后,crond 是 运行 作为一项服务。我 运行 遇到的另一个小问题是 run-parts
,执行 /etc/periodic
文件夹中文件的命令期望没有扩展名,所以我去掉了它,现在一切正常。
工作的 Docker 文件如下所示:
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"]
自上一个解决方案发布以来,Alpine 可能已经改变了工作方式,现在它只是返回报告:
# 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-initscripts”期间静默失败。
重要的一点是:
touch /run/openrc/softlevel
这让它起作用,请注意,您仍然需要安装之前解决方案的其余部分,即“openrc”和“busybox-initscripts”。
我正在尝试 运行 一个 Node 12.13.0 Alpine Docker 容器,该容器 运行 每 15 分钟执行一次脚本。根据 Alpine's wiki cron section,我应该可以通过以下方式将 Docker 文件中的 运行 任务添加到 运行 crond 作为服务:
rc-service crond start && rc-update add crond
然而returns这是一个错误:
rc-service: service `crond' does not exist
运行 一个单独的 Docker 容器 运行 针对此 Docker 容器的 cron 任务 不是 一个选项.这个容器已经非常轻量级了,并没有做太多事情。
这是我的Docker文件:
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"]
如有任何帮助,我们将不胜感激。
问题是一些 Alpine Docker 容器没有安装 busybox-initscripts package。安装后,crond 是 运行 作为一项服务。我 运行 遇到的另一个小问题是 run-parts
,执行 /etc/periodic
文件夹中文件的命令期望没有扩展名,所以我去掉了它,现在一切正常。
工作的 Docker 文件如下所示:
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"]
自上一个解决方案发布以来,Alpine 可能已经改变了工作方式,现在它只是返回报告:
# 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-initscripts”期间静默失败。
重要的一点是:
touch /run/openrc/softlevel
这让它起作用,请注意,您仍然需要安装之前解决方案的其余部分,即“openrc”和“busybox-initscripts”。