Docker with crontab



examples/crontab/Dockerfile
FROM ubuntu:20.04
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y cron

COPY crontab.txt /opt
RUN crontab /opt/crontab.txt

#RUN touch /var/log/cron.log
#CMD cron && tail -f /var/log/cron.log
CMD cron -f


examples/crontab/crontab.txt
* * * * * date >> /opt/dates.txt

docker build -t mydocker .
docker run -d --rm --name chronos mydocker

docker container cp chronos:/opt/dates.txt .

docker stop chronos