gpt4 book ai didi

docker - 在 Alpine 容器中启用 crond

转载 作者:行者123 更新时间:2023-12-02 18:06:02 37 4
gpt4 key购买 nike

语境
我正在尝试 日程安排 中的一些摄取工作 Alpine 容器。我花了一段时间才明白为什么我的 定时任务 没有启动:crond 似乎没有运行

rc-service -l | grep crond 
根据 Alpine's documentation , crond 必须首先以 openrc 开始(即某种 systemctl )。这是 Dockerfile
FROM python:3.7-alpine

# set work directory
WORKDIR /usr/src/collector

RUN apk update \
&& apk add curl openrc

# ======>>>> HERE !!!!!
RUN rc-service crond start && rc-update add crond

# install dependencies
RUN pip install --upgrade pip
RUN pip install pipenv
COPY ./Pipfile /usr/src/collector/Pipfile
RUN pipenv install --skip-lock --system --dev

# copy entrypoint.sh
COPY ./entrypoint.sh /usr/src/collector/entrypoint.sh

# copy project
COPY . /usr/src/collector/

# run entrypoint.sh
ENTRYPOINT ["/usr/src/collector/entrypoint.sh"]
entrypoint.sh仅在 /etc/crontabs/root 的末尾附加作业
问题
我收到以下错误:
 * rc-service: service `crond' does not exist
ERROR: Service 'collector' failed to build: The command '/bin/sh -c rc-service crond start && rc-update add crond' returned a non-zero code: 1
事情开始变得有点循环。 rc-service 如何同时不识别服务:
  • sh好像知道名字crond ,
  • 有一个 /etc/crontabs/root

  • 我错过了什么?

    最佳答案

    一些 Alpine Docker 容器缺少 busybox-initscripts package .只需将其附加到您的 apk add 的末尾命令,并且 crond 应该作为服务运行。

    您可能还需要从 Dockerfile 中删除以下行,因为它似乎是 busybox-initscripts 安装后立即将 crond 作为服务运行:

    RUN rc-service crond start && rc-update add crond

    关于docker - 在 Alpine 容器中启用 crond,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56901751/

    37 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com