Cron inside Docker. Looks for crontab at
Note: Does not use actual cron binary, as there are issues running it inside Docker.
Uses devcron instead.
This example mounts the folder containing your crontab file. Presumably you would
put your scripts in the same file and reference them in your crontab as
$ docker run -v /host/folder/containing/crontab:/cron -d hamiltont/docker-cron
This example mounts two folders, one with the crontab and one with the scripts. You need
/scripts/myscript.sh in your
$ docker run -v /host/folder/containing/crontab:/cron -v /host/folder/scripts:/scripts -d hamiltont/docker-cron
@hamiltont, thanks for providing this image. I am looking for a docker cron image runnable on OpenShift, which forbidding container process running as root. Your image is the only one compatible I can find. Keep up the good work!
Another issue you may encounter with cron and overlayfs:
Basically, cron fails hard on hardlinks, which are common in overlayfs setup. Still looking at a better solution, but using devcron is workable.
I have a small question/issue.
I've configured a daily cron job, but it runs at GMT 0:00 instead of my local timezone (CEST) 0:00.
Is there a way I can change this (without having to configure the crontab to run at an offset)
The main issues with the official cron is that it requires an environment to run a syslog daemon and a mail daemon for instance.
@jeverling - to be frank I don't remember what was going wrong. I think it had to do with cron requiring other system components to be running, but that may be incorrect. See http://programster.blogspot.com/2014/01/docker-working-with-cronjobs.html for someone else with problems just directly running cron in the foreground. FWIW, I'd love to just run cron in the container, this image also seems like a hack to me, but it's a hack that works and I just wanted something that got the job done when I made it. If you find a better container please comment here so I''m aware of it too :)
Hi, and thanks a lot for this image! Could you elaborate a bit on the issues you encountered when running the cron binary inside Docker? devcron works nice, but having to install mercurial and using a base-image with pip seems to be a lot of stuff for projects where Python isn't used otherwise.