Question 79 of 510
Scripting, Containers and AutomationmediumMultiple ChoiceObjective-mapped

Quick Answer

The answer is that the frontend container fails to resolve 'backend-service' because the backend container's hostname was overridden by a `container_name` directive in the docker-compose.yml file. Docker Compose’s embedded DNS normally creates a hostname matching the service name, so containers can reach each other using that service name. However, when `container_name` is explicitly set—for example, to 'my-backend'—that custom name replaces the default service-name hostname, breaking DNS resolution for any container still trying to reach 'backend-service'. On the CompTIA Linux+ XK0-005 exam, this scenario tests your understanding of Docker Compose networking and the subtle difference between service names and container names; a common trap is assuming the service name always works as a hostname. The fix is to either use the service name as the connection target or align the `container_name` with the expected hostname. Memory tip: “Service name is the DNS name—unless you rename the container, you’ll get an EAI_AGAIN.”

XK0-005 Scripting, Containers and Automation Practice Question

This XK0-005 practice question tests your understanding of scripting, containers and automation. 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 DevOps engineer is responsible for deploying a containerized web application on a Linux server running Docker. The application consists of three services: a frontend (Nginx), a backend (Node.js), and a database (PostgreSQL). The engineer uses Docker Compose to manage the stack. The deployment works correctly on a test environment, but when deployed to production, the frontend service fails to connect to the backend. Both services are on the same custom bridge network. The engineer checks the logs of the frontend container and sees 'getaddrinfo EAI_AGAIN backend-service'. The backend service is running and healthy. The engineer suspects a DNS resolution issue within the Docker network. Which of the following is the most likely cause and correct 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 1mediummultiple choice
Read the full DNS explanation →

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

The frontend container is trying to resolve 'backend-service' but the backend container's hostname is different because the container_name is set in the docker-compose.yml.

Option A is correct because the frontend container is attempting to resolve 'backend-service' via Docker's embedded DNS, but the backend container's hostname may differ if the `container_name` directive is set in the docker-compose.yml. Docker Compose creates a default hostname equal to the service name unless overridden by `container_name`. If `container_name` is set to something like 'my-backend', the DNS entry for 'backend-service' will not exist, causing an `EAI_AGAIN` (temporary failure in name resolution) error. The solution is to either use the correct hostname (the service name) or set `container_name` to match the expected hostname.

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.

  • The frontend container is trying to resolve 'backend-service' but the backend container's hostname is different because the container_name is set in the docker-compose.yml.

    Why this is correct

    If container_name is set, the service name is not used as the hostname; the frontend should use the container_name.

    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.

  • The containers are not on the same network because the default network driver is 'host' instead of 'bridge'.

    Why it's wrong here

    The default network driver is bridge, and the problem states they are on the same custom bridge network.

  • The backend service is listening on a different port than expected.

    Why it's wrong here

    The logs show a DNS resolution error, not a connection refused error.

  • The Docker DNS resolver is caching an old IP address for the backend service.

    Why it's wrong here

    Docker's embedded DNS does not cache stale entries in this manner.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates may assume the service name in docker-compose.yml always matches the DNS hostname, but Cisco tests the nuance that `container_name` overrides the default hostname, causing DNS resolution failures even when containers are on the same network.

Trap categories for this question

  • Command / output trap

    The logs show a DNS resolution error, not a connection refused error.

Detailed technical explanation

How to think about this question

Docker's embedded DNS server (127.0.0.11) resolves container names within user-defined bridge networks using the container's hostname or network alias. The `EAI_AGAIN` error is a temporary failure in name resolution, often caused by a non-existent hostname or a DNS server that is unreachable. In Docker Compose, the service name is used as the DNS hostname unless `container_name` overrides it, which can break service discovery. This is a common pitfall when migrating from a test environment where container names are not explicitly set.

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 practitioner preparing for the XK0-005 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

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 XK0-005 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 XK0-005 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 XK0-005 question test?

Scripting, Containers and Automation — This question tests Scripting, Containers and Automation — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The frontend container is trying to resolve 'backend-service' but the backend container's hostname is different because the container_name is set in the docker-compose.yml. — Option A is correct because the frontend container is attempting to resolve 'backend-service' via Docker's embedded DNS, but the backend container's hostname may differ if the `container_name` directive is set in the docker-compose.yml. Docker Compose creates a default hostname equal to the service name unless overridden by `container_name`. If `container_name` is set to something like 'my-backend', the DNS entry for 'backend-service' will not exist, causing an `EAI_AGAIN` (temporary failure in name resolution) error. The solution is to either use the correct hostname (the service name) or set `container_name` to match the expected hostname.

What should I do if I get this XK0-005 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

Last reviewed: Jun 11, 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 XK0-005 practice question is part of Courseiva's free CompTIA 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 XK0-005 exam.