I've been trying to set cron up within a Docker container. It is now working fine. What I want now is a log file.
This is my crontab:
* * * * * python /code/data_etl.py > /proc/1/fd/1 2> /proc/1/fd/2
My Dockerfile CMD is CMD ["cron", "-f"]
.
I was only able to get this working by following the answer here How to run a cron job inside a docker container?
I'm not 100% sure, but I believe the f
flag is running cron in the foreground, rather than as a background process.
However, I'm not sure why this line > /proc/1/fd/1 2> /proc/1/fd/2
is really necessary, and therefore, don't know how to amend it so that I can store a log file in my Docker container.