<p>Add any tiny http-server wrapper to your script and deploy your docker image as a <a href="https://cloud.google.com/run" rel="nofollow noreferrer">Cloud Run service</a> and use <a href="https://cloud.google.com/scheduler" rel="nofollow noreferrer">Cloud Scheduler</a> that will invoke it by cron.</p>
<p><a href="https://cloud.google.com/run/docs/triggering/using-scheduler" rel="nofollow noreferrer">https://cloud.google.com/run/docs/triggering/using-scheduler</a></p>

CC BY-SA 4.0
2021-12-22T09:40:21.067Z
2021-12-22T09:40:21.067Z
Nakilon
<p>I have 5 tasks in my project that need to be run periodically. Some of these tasks are run on a daily basis, some on a weekly basis.</p>
<p>I try to containerize each task in a Docker image. Here is one illustrative example:</p>
<pre><code>FROM tensorflow/tensorflow:2.7.0
RUN mkdir /home/MyProject
COPY . /home/MyProject
WORKDIR /home/MyProject/M1/src/
RUN pip install pandas numpy
CMD ./task1.sh
</code></pre>
<p>There are a list of Python scripts that need to be run in the task1.sh file defined above. This is not a server application or anything similar, it will run the task1.sh, which will run all the python scripts defined in it one by one, and the entire process will be finished within minutes. And the same process is supposed to be repeated 24 hours later.</p>
<p>How can I schedule such Docker containers in GCP? Are there different ways of doing it? Which one is comparably simpler if there are multiple solutions?</p>
<p>I am not a dev-ops expert by any means. All examples in documentation I find are explained for server applications which are running all the time, not like my example where the image needs to be run just once periodically. This topic is quite daunting for a beginner in this domain like myself.</p>

<docker><kubernetes><google-cloud-platform><gcp><google-kubernetes-engine>
how to schedule container in GCP
user33064
# how to schedule container in GCP

(Asked by: username_0 on 2021-12-18)

I have 5 tasks in my project that need to be run periodically. Some of these tasks are run on a daily basis, some on a weekly basis.
I try to containerize each task in a Docker image. Here is one illustrative example:
FROM tensorflow/tensorflow:2.7.0
RUN mkdir /home/MyProject
COPY . /home/MyProject
WORKDIR /home/MyProject/M1/src/
RUN pip install pandas numpy
CMD ./task1.sh

There are a list of Python scripts that need to be run in the task1.sh file defined above. This is not a server application or anything similar, it will run the task1.sh, which will run all the python scripts defined in it one by one, and the entire process will be finished within minutes. And the same process is supposed to be repeated 24 hours later.
How can I schedule such Docker containers in GCP? Are there different ways of doing it? Which one is comparably simpler if there are multiple solutions?
I am not a dev-ops expert by any means. All examples in documentation I find are explained for server applications which are running all the time, not like my example where the image needs to be run just once periodically. This topic is quite daunting for a beginner in this domain like myself.

**Tags:** docker, kubernetes, google-cloud-platform, gcp, google-kubernetes-engine


---

## 1 answers

### Answer by username_1 on 2021-12-22. Score: 2

Add any tiny http-server wrapper to your script and deploy your docker image as a [Cloud Run service](https://cloud.google.com/run) and use [Cloud Scheduler](https://cloud.google.com/scheduler) that will invoke it by cron.

<https://cloud.google.com/run/docs/triggering/using-scheduler>


---

