When I use docker build
to deploy to Cloud Run
, it keeps failing.
docker build --force-rm -t $IMAGE_NAME . --no-cache
docker push $IMAGE_NAME:latest
gcloud run deploy $CONTAINER_NAME
--image $IMAGE_NAME:latest
--region $REGION
--platform managed
--allow-unauthenticated
And Cloud Run shows:
ERROR: (gcloud.run.deploy) Revision 'test-app-container-00004-vlm' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined by the PORT=8080 environment variable. Logs for this revision might contain more information.
For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
However, when I try using Cloud Build, it works fine.
gcloud builds submit --tag $IMAGE_NAME
gcloud run deploy $CONTAINER_NAME
--image $IMAGE_NAME:latest
--region $REGION
--platform managed
--allow-unauthenticated
Extending my own question
I Finally Found the Problem – Hope This Helps Others Avoid the Same Issue T_____T
Upon checking the Cloud Run logs
, I saw the following:
WARNING 2024-09-12 Application exec likely failed
ERROR 2024-09-12 Default STARTUP TCP probe failed 1 time consecutively for container "example-1" on port 8080. The instance was not started.
I figured it might be due to an exec failure, which caused the Apache command to malfunction, preventing Cloud Run from properly communicating with port 8080.
This led me to think about an environment issue, specifically the MAC Apple chip.
When testing locally, I used the following command:
docker build --force-rm -t $IMAGE_NAME . --no-cache
Since I was using Docker on a Mac environment, the default --platform
was set to linux/arm64
. This triggered a series of issues that followed. I can only blame my bad habits.
When I used:
docker build --platform linux/amd64 --force-rm -t $IMAGE_NAME . --no-cache
Everything worked perfectly.
This issue can really make you search endlessly in the Dockerfile
, thinking it’s a configuration problem causing the port error XD
2