Run a Cron Job Inside of a Docker Container: Difference between revisions
Jump to navigation
Jump to search
Line 12: | Line 12: | ||
The procedure consists in building an image that contains cron, and that runs the cron daemon in foreground as shown below: | 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 | /usr/sbin/crond -n -s | ||
The daemon is configured to run in foreground, and also to log into syslog instead of sending e-mails. | |||
=Dockerfile= | =Dockerfile= |
Revision as of 20:40, 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 -s
The daemon is configured to run in foreground, and also to log into syslog instead of sending e-mails.
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"]