A quickstart recipe for running a Python script on a cron job inside a docker container.
- Replace
src/script.pywith your Python file. - Add any requirements for the Python script in
/src/requirements.txt. - Replace
src/crontab/with your desired cron (see https://crontab.guru/). - In the root directory, run
docker build -t IMAGE_NAME .docker run -d --name CONTAINER_NAME IMAGE_NAME(including any other arguments you might need e.g. environment variables)
Ensure src/script.py and src/crontab have Unix line endings.
For further CRON debugging see this post