I'm working on a project where there are four turtles in the middle of a circle, and they each follow a random path until one of them gets out. The last part is that if two or more turtles bump into each other, they go two steps back towards the center. I have everything except that, and I'm not sure how to proceed. Below is the code I have so far. Can anyone help? Thanks!

```
from random import randrange
import matplotlib.pyplot as plt
import numpy as np

def turtle1234():
    x_points = []
    y_points = []
    x2_points = []
    y2_points = []
    x3_points = []
    y3_points = []
    x4_points = []
    y4_points = []
    x = 0
    y = 0
    x2 = 0
    y2 = 0
    x3 = 0
    y3 = 0
    x4 = 0
    y4 = 0
    while True:
        x = x + randrange(-1,2)
        y = y + randrange(-1,2) 
        x2 = x2 + randrange(-1,2)
        y2 = y2 + randrange(-1,2) 
        x3 = x3 + randrange(-1,2)
        y3 = y3 + randrange(-1,2) 
        x4 = x4 + randrange(-1,2)
        y4 = y4 + randrange(-1,2) 
        x_points.append(x)
        y_points.append(y)
        x2_points.append(x2)
        y2_points.append(y2)
        x3_points.append(x3)
        y3_points.append(y3)
        x4_points.append(x4)
        y4_points.append(y4)
        if x**2+y**2 > 100**2:
            print(x,y)
            print('Turtle 1 is outside the circle first')
            break
        if x2**2+y2**2 > 100**2:
            print(x2,y2)
            print('Turtle 2 is outside the circle first')
            break
        if x3**2+y3**2 > 100**2:
            print(x3,y3)
            print('Turtle 3 is outside the circle first')
            break
        if x4**2+y4**2 > 100**2:
            print(x4,y4)
            print('Turtle 4 is outside the circle first')
            break
    plt.plot(x_points,y_points)
    plt.plot(x2_points,y2_points)
    plt.plot(x3_points,y3_points) 
    plt.plot(x4_points,y4_points) 
x = np.linspace(-100,100,1000)
turtle1234()

plt.plot(x,-np.sqrt(100**2-x**2), color = 'b')
plt.plot(x, np.sqrt(100**2-x**2), color = 'b')

```
['https://Stackoverflow.com/questions/68651869', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/16440183/']
You can't run background jobs on Cloud Run. Wrap it in a webserver as proposed by MBHA if the process take less than 1h.

Else you can you GKE Autopilot to run your container for a while. you pay only when your container run. And the first cluster is free. You can have a try on it!

As hack you can run your container in Cloud Build also, or in Vertex AI custom container training.
The explanation is in your question:

> 
> I am running a background task, nothing to expose
> 
> 
> 

A cloud run application, so your container, must be listening for incoming HTTP requests as stated in the [Container runtime contract](https://cloud.google.com/run/docs/reference/container-contract#port). That's why in all cloud run examples, java in your case, spring boot is used with `@RestController`. Other explanation can be found in [this answer](https://stackoverflow.com/a/55662223/8569928).

**Update:**
So the solution is either to

* add a webserver to your code and wrap it with spring boot and controller logic
* use Cloud Function rather than Cloud Run and get rid of the Dockerfile and in the same time have simpler code and less configuration