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:
Error: Cloud Run deployment failed
Container failed to start: health check failed on port 8080
Revision "my-service-001" is not readyCommon Causes
- 1.Container image not responding on configured port
- 2.Startup probe timeout too aggressive
- 3.Memory or CPU limit insufficient for startup
- 4.Health check endpoint not properly configured
Step-by-Step Fix
Step 1: Check Current State
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
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
gcloud run services describe my-service --region=us-central1 --format="value(status.url)"
gcloud run revisions describe my-service-001 --region=us-central1Common 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
Related Issues
- GCP Quota Exceeded
- GCP Resource Deployment Failed
- GCP Network Connectivity Issues
- GCP IAM Permission Denied