Update September 2017:
You are way better off running Docker cron jobs from your host system, not from inside your Docker containers. Your Docker containers should only have one concern only, and not be saddled with the weight of cron jobs.
Use this instead on your host system’s crontab:
* * * * * docker run --rm your-container /some/cool/task.sh
Original article:
In the same folder as your Dockerfile, create a file called
crontab
:* * * * * /some/cool/task.sh # Mandatory blank line
Then add the following to your Dockerfile:
COPY crontab /etc/cron.d/cool-task
RUN chmod 0644 /etc/cron.d/cool-task
RUN service cron start
Rebuild the Docker image, and you’re all set!
Comments
Post a Comment
https://gengwg.blogspot.com/