35 lines
1.2 KiB
Docker
35 lines
1.2 KiB
Docker
#
|
|
# crond Dockerfile
|
|
#
|
|
|
|
# Pull base image.
|
|
FROM debian:jessie
|
|
|
|
# Install Nginx.
|
|
RUN DEBIAN_FRONTEND=noninteractive \
|
|
apt-get update && \
|
|
apt-get install -y --no-install-recommends cron
|
|
|
|
# we need to make sure that /etc/cron.* cronjobs are not run as root
|
|
# it's not required for the operation (after all, all the cronjobs are to be
|
|
# doing is either some http requests, or some stuff against a database)
|
|
#
|
|
# first, remove the unnecessary cron.daily scripts
|
|
#
|
|
# then, change the user to nobody for cron.(hourly|daily|weekly|monthly),
|
|
# conveniently configured in /etc/crontab
|
|
#
|
|
# finally, make sure that this sed script runs every few minutes on all /etc/cron.d files
|
|
RUN rm -rf /etc/cron.*/* \
|
|
&& sed -i -r -e 's/^(([/0-9*,-]+\s+){5}|@(reboot|yearly|annually|monthly|weekly|daily|midnight|hourly)\s+)root\s+(.*)/\1\tnobody\t\4/' /etc/crontab \
|
|
&& echo "*/15 * * * * root sed -i -r -e 's/^(([/0-9*,-]+\s+){5}|@(reboot|yearly|annually|monthly|weekly|daily|midnight|hourly)\s+)root\s+(.*)/\\\1\\\tnobody\\\t\\\4/' /etc/cron.d/*" >> /etc/crontab
|
|
|
|
# cron volumes
|
|
VOLUME ["/etc/cron.d", "/etc/cron.daily", "/etc/cron.hourly", "/etc/cron.monthly", "/etc/cron.weekly"]
|
|
|
|
# well
|
|
WORKDIR /etc
|
|
|
|
# command and entrypoint
|
|
CMD []
|
|
ENTRYPOINT ["/usr/sbin/cron", "-f"] |