This is the way I ran my cron containers.
Dockerfile:
FROM alpine:3.3
ADD crontab.txt /crontab.txt
ADD script.sh /script.sh
COPY entry.sh /entry.sh
RUN chmod 755 /script.sh /entry.sh
RUN /usr/bin/crontab /crontab.txt
CMD ["/entry.sh"]
crontab.txt file:
*/30 * * * * /script.sh >> /var/log/script.log
entry.sh file:
#!/bin/sh
# start cron
/usr/sbin/crond -f -l 8
script.sh file:
#!/bin/sh
# code goes here.
echo "This is a script, run by cron!"
to buiild:
docker build -t mycron .
and finally to run:
docker run -d mycron
add the scripts you want, edit the crontab.txt and build the image. It should run now.