How to use Google Cloud Run for containerized apps
· Category: Cloud Computing
Short answer
Cloud Run deploys containers that automatically scale to zero and handle HTTP requests without managing servers.
Steps
- Build and push a container to Artifact Registry or Docker Hub.
- Deploy:
gcloud run deploy my-service --image gcr.io/project/my-image --platform managed
- Set concurrency, memory, and CPU limits.
- Map a custom domain and configure HTTPS.
Tips
- Cloud Run supports HTTP/2 and WebSockets.
- Use Cloud Tasks or Pub/Sub for asynchronous processing.
- Minimum instances reduce cold starts for latency-sensitive apps.
Common issues
- Container must listen on the PORT environment variable.
- Startup time affects cold start latency; keep images small.