hardMultiple ChoiceObjective-mapped
XK0-006 Practice Question: Given the Dockerfile in the exhibit, which best…
Exhibit
Refer to the exhibit. FROM ubuntu:20.04 RUN apt-get update RUN apt-get install -y python3 COPY app.py /app/ CMD ["python3", "/app/app.py"]
Given the Dockerfile in the exhibit, which best practice is being violated?
⚠ Common exam trap
CompTIA often tests the nuance that separating `apt-get update` and `apt-get install` is a caching and security violation, not just a style issue, and candidates may mistakenly focus on cache cleanup or .dockerignore as the primary problem.
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
✓
Not combining apt-get update and install in one RUN command
The Dockerfile violates the best practice of combining `apt-get update` and `apt-get install` in a single RUN command. When these are separated, Docker caches the layer from `apt-get update`, so subsequent builds may use a stale package index, potentially installing outdated or vulnerable packages. Combining them ensures that the update and install happen atomically, reducing image size and guaranteeing a fresh package index.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Not combining apt-get update and install in one RUN command
Why this is correct
Should be combined: RUN apt-get update && apt-get install -y python3
- ✗
Using a non-LTS base image
Why it's wrong here
20.04 is LTS.
- ✗
Not using a .dockerignore file
Why it's wrong here
Missing .dockerignore is not a best practice violation for this simple case.
- ✗
Running apt-get update without cache cleanup
Why it's wrong here
rm -rf /var/lib/apt/lists/* is recommended, but not the primary violation.
Go deeper
Related to this question
Learn chapter
Installing Linux and Package Management
Key term
apt
APT (Advanced Package Tool) is a command-line utility used in Debian-based Linux distributions to install, update, remove, and manage software packages from repositories.
Key term
Practice
Practice in IT service management refers to the repeated application of processes, procedures, and skills to improve efficiency, reduce errors, and maintain consistent service delivery.
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.