hardMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A DevOps engineer wants to reduce the size of a…
A DevOps engineer wants to reduce the size of a Docker image by combining build stages. Which Dockerfile feature should be used?
⚠ Common exam trap
A common mix-up: candidates confuse layer caching (a performance feature) with multi-stage builds (a size-reduction feature), or they assume using a smaller base image alone achieves the same result as eliminating entire build stages.
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
✓
Multi-stage builds (multiple FROM statements)
Multi-stage builds, implemented by using multiple FROM statements in a single Dockerfile, allow a DevOps engineer to copy only the necessary artifacts from intermediate build stages into the final image. This eliminates build-time dependencies, tools, and intermediate layers from the final image, significantly reducing its size without sacrificing build functionality.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
RUN --mount=type=cache
Why it's wrong here
Used for cache mounts, not multi-stage.
- ✗
Layer caching
Why it's wrong here
Helps build speed, not image size reduction.
- ✓
Multi-stage builds (multiple FROM statements)
Why this is correct
Copies only needed artifacts to final image.
- ✗
Using a smaller base image like Alpine
Why it's wrong here
Helps but not the feature for combining stages.
Go deeper
Related to this question
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.