Docker with crontab with tail
A way to overcome this problem is to create a process that will run forever. A way to accomplish this is to create an empty file and then run tail -f on that file. That tail command is supposed to display the content of the file as it growth, but the file does not change so this command will just wait there.
Enough for the Docker container to keep running.
As you can see the name of the file does not matter.
FROM ubuntu:20.04 RUN apt-get update && \ apt-get install -y cron COPY crontab.txt /opt RUN crontab /opt/crontab.txt RUN touch /opt/jumanji.txt CMD ["cron", "&&", "tail", "-f", "/opt/jumanji.txt"]
docker build -t mydocker . docker run -d --rm --name chronos mydocker docker container cp chronos:/opt/dates.txt . docker container stop chronos