Question

Difficulty: MediumDeploying Serverless Applications with Cloud Run and Cloud Functions

A developer has packaged a web microservice into a custom container image. The internal web server inside the container is configured to listen strictly on port 8000. When deploying this container image to Google Cloud Run using the gcloud CLI, which command flag must be included to ensure Cloud Run correctly routes incoming HTTP requests to the application?

  1. Pass the --port=8000 flag during the gcloud run deploy execution.Answer
  2. B
    Deploy the application to Cloud Functions Gen 2 instead, which automatically detects and exposes custom internal listener ports.
  3. C
    Set an environment variable PORT=8080 in the container configuration without altering the application's internal listener port of 8000.
  4. D
    Grant the deployment service account the Owner primitive role so Cloud Run can inspect and bind to open container ports dynamically.

Answer

Pass the --port=8000 flag during the gcloud run deploy execution.
By default, Cloud Run sends ingress requests to port 8080 inside the container. Supplying the --port=8000 flag during deployment configures Cloud Run to direct ingress traffic to port 8000, aligning with the application's internal listener port.

Step-by-Step Solution

1
Analyze container listening port configuration.
Identify that the web application inside the container listens strictly on port 8000.
Cloud Run defaults to sending traffic to port 8080 inside the container unless configured otherwise.
2
Identify the proper gcloud CLI parameter to override default port routing.
Use --port=8000 with gcloud run deploy.
The --port flag informs Cloud Run of the container's listening port so ingress traffic is routed properly.

Key Concept

Cloud Run Custom Container Port Configuration
Rate this question