A developer packaged a Node.js REST API into a container image where the application server strictly listens on internal TCP port 8000 without reading the PORT environment variable. When deploying this container image to Google Cloud Run using the standard gcloud CLI command, deployment fails because startup health checks time out. How should the developer configure the deployment to successfully serve traffic on Cloud Run without modifying the application source code?
- ASet the deployment environment variable using `--set-env-vars=PORT=8080` in the gcloud run deploy command.
- BRe-deploy the container image using `gcloud functions deploy` with the `--trigger-http` flag.
- Include the `--port=8000` flag during the `gcloud run deploy` command execution.Cevap
- DGrant the default compute service account the `roles/owner` primitive role across the project.
Cevap
Include the `--port=8000` flag during the `gcloud run deploy` command execution.
Cloud Run defaults to sending ingress traffic to port 8080 inside the container. When an application hardcodes listening on port 8000 and ignores the PORT environment variable, specifying `--port=8000` in `gcloud run deploy` configures Cloud Run to route traffic to port 8000, resolving health check timeouts.
Adım Adım Çözüm
Anahtar Kavram
Cloud Run Custom Container Port Binding