Introduction

GCP Cloud Run deployment fails when container image or resource limits invalid. This guide provides step-by-step diagnosis and resolution.

Symptoms

Typical error output:

bash
Error: Cloud Run deployment failed
Container failed to start: health check failed on port 8080
Revision "my-service-001" is not ready

Common Causes

  1. 1.Container image not responding on configured port
  2. 2.Startup probe timeout too aggressive
  3. 3.Memory or CPU limit insufficient for startup
  4. 4.Health check endpoint not properly configured

Step-by-Step Fix

Step 1: Check Current State

bash
gcloud run services describe my-service --region=us-central1
gcloud run revisions list --service=my-service --region=us-central1
gcloud logging read "resource.type=cloud_run_revision"

Step 2: Identify Root Cause

bash
gcloud logging read --project=<project> --filter="severity>=ERROR"

Step 3: Apply Primary Fix

```bash # Update service with correct port and health check gcloud run services update my-service --region=us-central1 --port=8080 --timeout=300 --cpu=2 --memory=512Mi

# Deploy new revision gcloud run deploy my-service --image=gcr.io/my-project/my-image:latest --region=us-central1 ```

Step 4: Apply Alternative Fix

```bash # Alternative fix: Check configuration gcloud resource describe <resource> --project=<project> --format=yaml

# Update specific properties gcloud resource update <resource> --project=<project> --<flag>=<value>

# Verify the fix gcloud resource describe <resource> --project=<project> --format=json ```

Step 5: Verify the Fix

bash
gcloud run services describe my-service --region=us-central1 --format="value(status.url)"
gcloud run revisions describe my-service-001 --region=us-central1

Common Pitfalls

  • Forgetting to check regional quotas before provisioning
  • Not waiting for async operations to complete before next step
  • Missing IAM permissions for GCP resource operations
  • Confusing zone-level and region-level resources

Best Practices

  • Always check quotas before provisioning new resources
  • Use GCP Cloud Monitoring for observability
  • Implement proper error handling in gcloud scripts
  • Enable logging for all critical GCP resources
  • GCP Quota Exceeded
  • GCP Resource Deployment Failed
  • GCP Network Connectivity Issues
  • GCP IAM Permission Denied