I have a dockerfile
FROM python:3.9.12-bullseye
COPY . .
RUN apt-get update -y
RUN apt-get install cron -y
RUN crontab crontab
CMD python task.py && crond -f
And a crontab
* * * * * python /task.py
I keep running into the error /bin/sh: 1: crond: not found when I run the docker file. Docker build is fine.
Anyone knows why this happens? If I use python:3.6.12-alpine everything works fine but with python:3.9.12-bullseye, i keep getting that error.
If you have a look for debian series cron.service, you could see next:
[Unit]
Description=Regular background program processing daemon
Documentation=man:cron(8)
After=remote-fs.target nss-user-lookup.target
[Service]
EnvironmentFile=-/etc/default/cron
ExecStart=/usr/sbin/cron -f $EXTRA_OPTS
IgnoreSIGPIPE=false
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
From ExecStart=/usr/sbin/cron -f $EXTRA_OPTS, I guess unlike alpine, the main program on such debian series linux could be cron not crond.
(PS: python:3.9.12-bullseye based on debian, while python:3.6.12-alpine based on alpine)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With