Home > database >  Docker containers runs great locally. Now I need it on schedule in cloud
Docker containers runs great locally. Now I need it on schedule in cloud

Time:11-15

I've containerized a logic that I have to run on a schedule. If I do my docker run locally (whatever my image is local or it is using the one from the hub) everything works great.

Now I need though to run that "docker run" on a scheduled base, on the cloud.

Azure would be preferred, but honestly, I'm looking for the easier and cheapest way to achieve this goal.

Moreover, my schedule can change, so maybe today that job runs once a day, in the future that can change.

What do you suggest?

CodePudding user response:

You can create an enter image description here

CodePudding user response:

Professionally I used 4 ways to run cron jobs/ scheduled builds. I give a quick summary of all with it pros/cons.

GitLab scheduled builds

My personal preference would be to setup a scheduled pipeline in GitLab. Simply add the script to a .gitlab-ci.yml, configure the scheduled build and you are done. This is the lightweight option and works in most cases, if the execution time is not too long. I used this approach for scraping simple pages.

Jenkins scheduled builds

I used the same approach as GitLab with Jenkins. But Jenkins comes with more overhead and you have to configure the entire Jenkins on multiple machines.

Kubernetes CronJob

My third approach would be using a kubernetes cronjob. However, I would only use this if I consume a lot of memory/ram, or have a long execution time. I used this approach for dumping really large data sets.

Run a cron job from a container

My last option would be to deploy a docker container on either a VM or a Kubernetes cluster and configure a cron job from within that docker container. You can even use docker-in-docker for that. This gives maximum flexibility, but comes with some challenges. Personally I like the separation of concerns when it comes to down-times etc. That's why never run a cron job as main process.

  • Related