Public | Automated Build

Last pushed: a year ago
Short Description
Run Cron jobs inside Docker container
Full Description


Use Cron inside Docker. Looks for crontab at /cron/crontab

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 /cron/

$ 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
to use /scripts/ in your crontab

$ docker run -v /host/folder/containing/crontab:/cron -v /host/folder/scripts:/scripts -d hamiltont/docker-cron
Docker Pull Command
Source Repository

Comments (6)
7 months ago

@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!

a year ago

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.

a year ago

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)

2 years ago

The main issues with the official cron is that it requires an environment to run a syslog daemon and a mail daemon for instance.

3 years ago

@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 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 :)

3 years ago

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.