Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run cron inside a docker container.
env - `cat /root/env.sh` /bin/bash -c $1 >> /var/log/cron.log 2>&1
# Run every 30 minutes on Wednesday
*/30 * * * 3 /root/cron_task.sh /root/run_app.sh
# cron needs an empty line at the end, leave this here.
FROM microsoft/dotnet
MAINTAINER Chris
# Fix from:
# https://github.com/bringnow/docker-letsencrypt-manager/commit/7a157dcd05ea8e745ec604734f6e7aa2e9e7b7cc
# Put cron logfiles into a volume. This also works around bug
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810669
# caused by base image using old version of coreutils
# which causes "tail: unrecognized file system type 0x794c7630 for '/var/log/cron.log'"
# when using docker with overlay storage driver.
VOLUME /var/log/
RUN mkdir /app
COPY ./src/MyApp/bin/Debug/netcoreapp1.0/publish /app
WORKDIR /app
RUN apt-get update
RUN apt-get install -y cron
ADD *.sh /root/
RUN chmod 750 /root/cron_task.sh
RUN chmod 750 /root/run_redditbot.sh
RUN chmod 750 /app/
ADD crontab /var/spool/cron/crontabs/root
RUN chmod 0600 /var/spool/cron/crontabs/root
CMD touch /var/log/cron.log && cron && env > /root/env.sh && tail -f /var/log/cron.log
dotnet /app/MyApp.dll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.