【发布时间】:2020-07-31 00:53:09
【问题描述】:
如果我在我的容器中运行一个 pythonscript,它运行没有任何问题。但是当我将它作为 cronjob 运行时,它会抛出一个错误,它没有找到任何模块。你有什么想法为什么?
码头文件
FROM python:3.5.2
RUN apt-get update \
&& apt-get install -y cron \
&& apt-get autoremove -y
RUN pip install --upgrade pip && \
pip install --no-cache-dir image pytesseract numpy XlsxWriter pandas requests && \
pip install --no-cache-dir med2image datetime IPython matplotlib
# Create a volume
VOLUME /logSent
# Copy Scriptfile
COPY script.py ./script.py
# Copy cron file to the cron.d directory
COPY cronpy /etc/cron.d/cronpy
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cronpy
# Apply cron job
RUN crontab /etc/cron.d/cronpy
CMD ["cron", "-f"]
cronpy
*/10 * * * * python /script.py > /proc/1/fd/1 2>/proc/1/fd/2
# Empty line
【问题讨论】: