Docker Community Forums

Share and learn in the Docker community.

Cron in Alpine Docker

cronscript.sh
#!/bin/sh
echo “Job started: $(date)”

Add additional instructions

echo “Job finished: $(date)”

Dockerfile

FROM python:3.7-alpine
COPY cronscript.sh /etc/periodic/15min/test
RUN chmod 755 /etc/periodic/15min/test
CMD [ “crond”, “-l”, “2”, “-f” ]

Build went fine, cronscript file get created, but when i run the container get this error
“run-parts: can’t execute ‘/etc/periodic/15min/test’: No such file or directory”

really strange. Even though file is there with right permission, cron triggers but cant see the file. No files in /var/log

What i am trying to do successfully running a cron.

Ref: https://gist.github.com/AntonFriberg/692eb1a95d61aa001dbb4ab5ce00d291

ok found the issue. I am running Docker desktop on Windows. so i had to add one more line in the Dockerfile

RUN dos2unix /etc/periodic/15min/test