Question 396 of 500
Building and testing applicationseasyMultiple ChoiceObjective-mapped

Quick Answer

The answer is to explicitly set the PORT environment variable to 8080 in the Cloud Run service configuration. This is necessary because Cloud Run injects the PORT environment variable into the container at runtime, defaulting to 8080, and expects the application to bind to whatever port that variable specifies. Even though your container runs fine locally on port 8080, the error "Container failed to start and then listen on the port defined by the PORT environment variable" indicates the application is hardcoded to listen on 8080 rather than reading the PORT variable, or it is binding to localhost instead of 0.0.0.0, which Cloud Run cannot reach. On the Google Professional Cloud Developer exam, this scenario tests your understanding of Cloud Run’s contract: the container must be stateless and respect the dynamic port assignment. A common trap is assuming local behavior mirrors Cloud Run’s environment, but the key difference is that Cloud Run requires the app to listen on all interfaces (0.0.0.0) and obey the PORT variable. Memory tip: "Listen to PORT, not to 8080—Cloud Run sets the table, your app must take the seat."

PCD Building and testing applications Practice Question

This PCD practice question tests your understanding of building and testing applications. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A team deploys a containerized web application on Cloud Run. The deployment fails with error 'Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.' The container image runs fine locally on port 8080. The team has not set any environment variables in the Cloud Run service configuration. What is the most likely issue and solution?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Question 1easymultiple choice
Full question →

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Set the PORT environment variable to 8080 in the Cloud Run service configuration.

Cloud Run expects the container to listen on the port specified by the PORT environment variable, which defaults to 8080. Since the team did not set any environment variables, Cloud Run assigns PORT=8080 automatically. The container runs fine locally on port 8080, but the error indicates it is not listening on the port defined by PORT. The most likely issue is that the container is hardcoded to listen on port 8080 but does not respect the PORT environment variable, or the application is binding to a different interface (e.g., localhost) that Cloud Run cannot reach. Setting the PORT environment variable explicitly to 8080 in the Cloud Run service configuration ensures the container listens on the expected port.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Set the PORT environment variable to 8080 in the Cloud Run service configuration.

    Why this is correct

    This ensures the container listens on the expected port. Cloud Run injects PORT but the container must use it.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Configure a health check for the container.

    Why it's wrong here

    Health checks are used after startup; they do not fix port binding issues.

  • Increase the container concurrency setting.

    Why it's wrong here

    Concurrency affects requests per container instance, not the port it listens on.

  • Set min instances to 1 to keep the container warm.

    Why it's wrong here

    Min instances reduce cold starts but do not affect the port the container listens on.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Cisco often tests the misconception that the PORT environment variable is optional or that Cloud Run will automatically map a hardcoded port; the trap here is that candidates assume the container's hardcoded port 8080 will work without explicitly setting the PORT variable, but Cloud Run strictly requires the container to listen on the port specified by the PORT environment variable, which defaults to 8080 only if the container respects it.

Detailed technical explanation

How to think about this question

Cloud Run injects the PORT environment variable (default 8080) into the container and expects the application to bind to 0.0.0.0 on that port. If the application is hardcoded to a specific port (e.g., 8080) but does not read the PORT variable, or if it binds to 127.0.0.1 instead of 0.0.0.0, the container will fail the startup probe. This is a common issue when migrating from local Docker runs where port mapping is explicit, but Cloud Run requires the container to be stateless and listen on the dynamic PORT variable. The error message 'Failed to start and then listen on the port defined by the PORT environment variable' is a direct indication that the container is not binding to the correct interface or port.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCD practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCD practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCD question test?

Building and testing applications — This question tests Building and testing applications — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Set the PORT environment variable to 8080 in the Cloud Run service configuration. — Cloud Run expects the container to listen on the port specified by the PORT environment variable, which defaults to 8080. Since the team did not set any environment variables, Cloud Run assigns PORT=8080 automatically. The container runs fine locally on port 8080, but the error indicates it is not listening on the port defined by PORT. The most likely issue is that the container is hardcoded to listen on port 8080 but does not respect the PORT environment variable, or the application is binding to a different interface (e.g., localhost) that Cloud Run cannot reach. Setting the PORT environment variable explicitly to 8080 in the Cloud Run service configuration ensures the container listens on the expected port.

What should I do if I get this PCD question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Keep practising

More PCD practice questions

Last reviewed: Jun 25, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PCD practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCD exam.