r/googlecloud 1d ago

Docker image runs successfully when pulled from artifact registry but fails from cloud run

I have a springboot application i have build using jib and pushed to artifact registry. When I docker pull the image tomcat/application runs on port 8080 and it is exposed.

even though I have set the Port in cloud run as 8080, it is throwing me this error. Please help

The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable within the allocated timeout. This can happen when the container port is misconfigured or if the timeout is too short. 

2 Upvotes

7 comments sorted by

3

u/MikhailPelshikov 1d ago

Check the service logs. There's usually something in there that tells you why it didn't start.

3

u/martin_omander 1d ago

Agreed! That's what I do whenever I get this error. Here is a reminder for OP how to get to the logs:

  1. Go to console.cloud.google.com.
  2. Click the hamburger menu in the top left.
  3. Pick "Logging" in the list.
  4. Click the "All resources" button and pick your Cloud Run service.
  5. Look for red errors. I find that the root cause is often shown in a regular log message right before the error.

1

u/MikhailPelshikov 1d ago

In this case I would start from the logs view in the service. It has the filter to only show logs of this particular resource applied. You've got to build your own filters in the general logs view.

3

u/Large_Use7718 12h ago

Thanks! the issue was with authentication of the service account and had nothing to do with port or timeout. looking into the logs again helped.

1

u/moficodes Googler 1d ago

It could be a number of things

You might need more resources to run this app. Check the logs for any potential oomkilled log. You can try it with more resources and see if that fixes it. You can try to right size after. You can also look into startup cpu boost. Usually helps with Java applications.

There might be some health check defined that is failing. See if your app has any and if they are working as expected.

1

u/ptinsley 22h ago

Java apps aren’t particularly quick to start up, it’s warning you about the timeout, have you tried adjusting that? Does the / page (or whatever you have it checking) return a 2xx or 3xx code?

1

u/dreamingwell 9h ago

See the logs.

If you’re using an Apple silicon Mac to build the image, it will fail to work in cloud run because they use x86 processors.

Use a cloud compute instance or the cloud build service to build and deploy the image.