hardMultiple ChoiceObjective-mapped
XK0-006 Practice Question: After building and running the container as shown…
Exhibit
Refer to the exhibit. ``` $ cat Dockerfile FROM ubuntu:22.04 RUN apt-get update && apt-get install -y nginx COPY index.html /var/www/html/ EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] $ docker build -t webapp . $ docker run -d -p 8080:80 webapp ```
After building and running the container as shown in the exhibit, the administrator tries to access http://localhost:8080 but receives a connection refused error. What is the most likely cause?
⚠ Common exam trap
CompTIA often tests the distinction between a container that fails to start (e.g., due to syntax errors) and one that starts but exits immediately, where the 'connection refused' error is a symptom of the latter.
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 container exited immediately after starting.
The most likely cause is that the container exited immediately after starting. When a container runs a command that finishes quickly (e.g., a shell script that exits), the container stops, and no process listens on port 8080. This results in a 'connection refused' error because the container is no longer running to accept connections.
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 container exited immediately after starting.
Why this is correct
Check docker ps to see if running.
- ✗
The port mapping is incorrect.
Why it's wrong here
Mapping is correct.
- ✗
The base image is not compatible.
Why it's wrong here
Ubuntu is compatible.
- ✗
The CMD syntax is incorrect.
Why it's wrong here
CMD syntax is valid.
Go deeper
Related to this question
Learn chapter
Process Management and System Monitoring
Key term
Shell
A shell is a computer program that provides a user interface to access an operating system's services, typically by accepting text commands.
Key term
Process
In IT service management, a process is a structured set of activities designed to accomplish a specific objective, such as managing incidents or changes, by transforming inputs into defined outputs.
About these practice questions
One of 979 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 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-006 exam.