How to run my docker container on a schedule?

  • Posted February 14, 2022
  • Docker

I have a webscraper written in python that I have in a docker container. I’d like to run it on a set schedule. I am confused on how to do this. any help would be appreciated


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello there,

I believe that using a cron job with satisfy your needs. In this way, you can set a schedule and specify at what time the docker container will be started.

You can check our article on How To Use Cron to Automate Tasks on Ubuntu 18.04

An example command will be:

  1. */5 * * * * docker exec docker_container

This will execute the cron job every five minutes.

Hope that this helps!

Regards, Alex