How to schedule a docker run on google cloud
Asked Answered
A

2

9

There are 3 batches in my project. I have put all 3 batches in a single docker image. Now to run any particular batch I invoke the docker run with command line argument, which is taken into account by a shell script and launches appropriate batch inside the image.

Now to schedule these 3 batches at a different time period, I can use 3 commands for same docker images with proper arguments. But how to deploy (app engine or gke) and from where to fire the command? In cloud scheduler there is only Pub Sub / HTTP Url firing options are available. So not able to find any way out.

Can you suggest ?

Thanks in advance.

Regards,

Arindam

Acetum answered 17/3, 2019 at 0:10 Comment(0)
S
4

Your question raises questions but -- first -- why do you wish to employ App Engine or GKE?

IIUC you likely could solve your problem using Kubernetes CronJobs: https://cloud.google.com/kubernetes-engine/docs/how-to/cronjobs

Cloud Scheduler's use of HTTP and Pub/Sub is because this provides the service with a general-purpose way to fire its events. If you wished to pursue Cloud Scheduler, you could develop a companion (aka "sidecar") image that exposes an e.g. HTTP interface and, when invoked, it runs the correct command against your container. You then program Cloud Scheduler to invoke the sidecars on your schedule and they, in turn, invoke your container image. Something similar to this approach is employed in the Cloud Scheduler example here: https://cloud.google.com/scheduler/docs/start-and-stop-compute-engine-instances-on-a-schedule#set_up_the_functions_with

If you don't wish to use Kubernetes, I think the easiest solution would be for you to create a Compute Engine instance that runs your cron schedule and it simply invokes the appropriate docker run commands on your image as needed.

Shrovetide answered 17/3, 2019 at 0:35 Comment(0)
W
1

You can add an http-server wrapper to your image and deploy it as a Cloud Run service and use Cloud Scheduler to invoke it by cron.

Willodeanwilloughby answered 10/9, 2022 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.