[GH-ISSUE #9133] Help Needed: Cloud Run Deployment Failing to Listen on PORT 8080 Google Cloud Run #5940

Closed
opened 2026-04-12 17:17:02 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @nvip12041994 on GitHub (Feb 15, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9133

I’m experiencing an issue deploying my container image to Cloud Run. I followed the GPU Gemma2 with Ollama tutorial and built my Docker image successfully. The container runs correctly locally, but when I deploy it to Cloud Run, it fails to start.

Dockerfile:

FROM ollama/ollama:0.5.11
ENV HOME=/home
ENV PORT=8080
ENV OLLAMA_HOST=0.0.0.0:${PORT}
ENV OLLAMA_MODELS=${HOME}/.ollama/models
ENV OLLAMA_DEBUG=false
ENV OLLAMA_KEEP_ALIVE=-1
ENV MODEL=llama3.2
RUN ollama serve & sleep 5 && ollama pull $MODEL && ollama run llama3.2 ""
EXPOSE 8080

After build and successfully run on local and push image to cloud I use the following command to deploy to google cloud run:

gcloud beta run deploy ollama-llama
--image asia-southeast1-docker.pkg.dev/extract-financial-data/ollama-repo/ollama_llama:0.5.11
--concurrency 4
--cpu 8
--set-env-vars OLLAMA_NUM_PARALLEL=4
--gpu 1
--gpu-type nvidia-l4
--max-instances 1
--memory 32Gi
--no-allow-unauthenticated
--no-cpu-throttling
--service-account ollama@extract-financial-data.iam.gserviceaccount.com
--timeout=600

Error Message:

`
Deploying container to Cloud Run service [ollama-llama] in project [extract-financial-data] region [asia-southeast1]
X Deploying...

  • Creating Revision...
    . Routing traffic...
    ✓ Setting IAM Policy...
    Deployment failed
    ERROR: (gcloud.beta.run.deploy) Revision 'ollama-llama-00004-r8l' is not ready and cannot serve traffic. 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. The health check timeout can be extended. Logs for this revision might contain more information.

Logs URL: https://console.cloud.google.com/logs/viewer?project=extract-financial-data&resource=cloud_run_revision/service_name/ollama-llama/revision_name/ollama-llama-00004-r8l&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22ollama-llama%22%0Aresource.labels.revision_name%3D%22ollama-llama-00004-r8l%22
For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
`

Details:

  • I have set the container to listen on port 8080 (as required by Cloud Run) via the PORT environment variable.

  • The Dockerfile sets up the environment and starts the Ollama service, pulls the model, and runs the model.

  • The container works locally, but on Cloud Run the revision fails to become ready, suggesting the container isn’t listening on the specified port within the timeout period.

  • I’ve verified the port configuration and environment variables, but the issue persists.

Could you please help me troubleshoot this issue? Any guidance on whether the problem might be related to port configuration, health check timeouts, or another aspect of the deployment would be greatly appreciated.

Thank you in advance for your help!

Originally created by @nvip12041994 on GitHub (Feb 15, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9133 I’m experiencing an issue deploying my container image to Cloud Run. I followed the [GPU Gemma2 with Ollama tutorial](https://cloud.google.com/run/docs/tutorials/gpu-gemma2-with-ollama) and built my Docker image successfully. The container runs correctly locally, but when I deploy it to Cloud Run, it fails to start. Dockerfile: > FROM ollama/ollama:0.5.11 ENV HOME=/home ENV PORT=8080 ENV OLLAMA_HOST=0.0.0.0:${PORT} ENV OLLAMA_MODELS=${HOME}/.ollama/models ENV OLLAMA_DEBUG=false ENV OLLAMA_KEEP_ALIVE=-1 ENV MODEL=llama3.2 RUN ollama serve & sleep 5 && ollama pull $MODEL && ollama run llama3.2 "" EXPOSE 8080 After build and successfully run on local and push image to cloud I use the following command to deploy to google cloud run: > gcloud beta run deploy ollama-llama \ --image asia-southeast1-docker.pkg.dev/extract-financial-data/ollama-repo/ollama_llama:0.5.11 \ --concurrency 4 \ --cpu 8 \ --set-env-vars OLLAMA_NUM_PARALLEL=4 \ --gpu 1 \ --gpu-type nvidia-l4 \ --max-instances 1 \ --memory 32Gi \ --no-allow-unauthenticated \ --no-cpu-throttling \ --service-account ollama@extract-financial-data.iam.gserviceaccount.com \ --timeout=600 Error Message: ` Deploying container to Cloud Run service [ollama-llama] in project [extract-financial-data] region [asia-southeast1] X Deploying... - Creating Revision... . Routing traffic... ✓ Setting IAM Policy... Deployment failed ERROR: (gcloud.beta.run.deploy) Revision 'ollama-llama-00004-r8l' is not ready and cannot serve traffic. 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. The health check timeout can be extended. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=extract-financial-data&resource=cloud_run_revision/service_name/ollama-llama/revision_name/ollama-llama-00004-r8l&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22ollama-llama%22%0Aresource.labels.revision_name%3D%22ollama-llama-00004-r8l%22 For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start ` Details: - I have set the container to listen on port 8080 (as required by Cloud Run) via the PORT environment variable. - The Dockerfile sets up the environment and starts the Ollama service, pulls the model, and runs the model. - The container works locally, but on Cloud Run the revision fails to become ready, suggesting the container isn’t listening on the specified port within the timeout period. - I’ve verified the port configuration and environment variables, but the issue persists. Could you please help me troubleshoot this issue? Any guidance on whether the problem might be related to port configuration, health check timeouts, or another aspect of the deployment would be greatly appreciated. Thank you in advance for your help!
Author
Owner

@rick-github commented on GitHub (Feb 16, 2025):

What's in the logs?

<!-- gh-comment-id:2661521889 --> @rick-github commented on GitHub (Feb 16, 2025): What's in the logs?
Author
Owner

@Programming-Seungwan commented on GitHub (Mar 31, 2025):

Did you resolved that problem?

<!-- gh-comment-id:2765245804 --> @Programming-Seungwan commented on GitHub (Mar 31, 2025): Did you resolved that problem?
Author
Owner

@petem24 commented on GitHub (Apr 10, 2025):

+1

<!-- gh-comment-id:2794754511 --> @petem24 commented on GitHub (Apr 10, 2025): +1
Author
Owner

@SieSiongWong commented on GitHub (Jun 7, 2025):

Is this resolved? I encountered the similar problem.

<!-- gh-comment-id:2951786667 --> @SieSiongWong commented on GitHub (Jun 7, 2025): Is this resolved? I encountered the similar problem.
Author
Owner

@laurentiuspurba commented on GitHub (Jun 20, 2025):

Why this is closed?

Did you build the image in Mac? That's what happened to me. I build that image on Mac without --platform linux/amd64 parameter.

It's probably different issue with what you encountered, but that's what happened to me. Good luck!!!

<!-- gh-comment-id:2992409307 --> @laurentiuspurba commented on GitHub (Jun 20, 2025): Why this is closed? Did you `build` the image in Mac? That's what happened to me. I `build` that image on Mac without `--platform linux/amd64` parameter. It's probably different issue with what you encountered, but that's what happened to me. Good luck!!!
Author
Owner

@craffulz commented on GitHub (Jul 25, 2025):

same here, im going crazy

Is this resolved? I encountered the similar problem.

<!-- gh-comment-id:3115933427 --> @craffulz commented on GitHub (Jul 25, 2025): same here, im going crazy > Is this resolved? I encountered the similar problem.
Author
Owner

@imraann0 commented on GitHub (Dec 9, 2025):

i updated to node 20 now i am getting this what is the issue please

<!-- gh-comment-id:3634525563 --> @imraann0 commented on GitHub (Dec 9, 2025): i updated to node 20 now i am getting this what is the issue please
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5940