Run a Cron Job Inside of a Docker Container: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * https://www.ekito.fr/people/run-a-cron-job-with-docker/ =Internal= * Docker Recipes")
 
Line 5: Line 5:
=Internal=
=Internal=


* [[Cron#cron_Inside_a_Container|cron]]
* [[Docker Recipes#Recipes|Docker Recipes]]
* [[Docker Recipes#Recipes|Docker Recipes]]
=Overview=
The procedure consists in building an image that contains cron, and that runs the cron daemon in foreground as shown below:
/usr/sbin/crond -n
=Dockerfile=
FROM centos:latest
RUN yum install -y crontabs logrotate
RUN echo "* * * * * root /opt/activity" >> /etc/crontab
COPY ./activity /opt/activity
ENTRYPOINT ["/usr/sbin/crond", "-n"]

Revision as of 19:45, 12 February 2018

External

Internal

Overview

The procedure consists in building an image that contains cron, and that runs the cron daemon in foreground as shown below:

/usr/sbin/crond -n

Dockerfile

FROM centos:latest
RUN yum install -y crontabs logrotate
RUN echo "* * * * * root /opt/activity" >> /etc/crontab
COPY ./activity /opt/activity
ENTRYPOINT ["/usr/sbin/crond", "-n"]