I want to repeatedly call a script via cron in a docker container, but when I switch from one time execution to execution via cron the official python image suddenly can't seem to find python.
Dockerfile:
FROM python:3.7-slim
COPY main.py /home/main.py
#A: works
CMD [ "python", "/home/main.py" ]
#B: doesn't work
#RUN apt-get update && apt-get -y install -qq --force-yes cron
#COPY hello-cron /etc/cron.d/hello-cron
#CMD ["cron", "-f"]
main.py
import time
for i in range(90000):
print(i)
time.sleep(5000)
hello-cron:
* * * * * root python /home/main.py > /proc/1/fd/1 2> /proc/1/fd/2
#
When I switch A for B in the Dockerfile the error message is: /bin/sh: 1: python: not found
Thank you all for he quick responses! Adding PATH=/usr/local/bin
in the cron file solved my problem.