Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Run cron inside a docker container.
env - `cat /root/` /bin/bash -c $1 >> /var/log/cron.log 2>&1
# Run every 30 minutes on Wednesday
*/30 * * * 3 /root/ /root/
# cron needs an empty line at the end, leave this here.
FROM microsoft/dotnet
# Fix from:
# Put cron logfiles into a volume. This also works around bug
# 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
RUN apt-get update
RUN apt-get install -y cron
ADD *.sh /root/
RUN chmod 750 /root/
RUN chmod 750 /root/
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/ && 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.