KCNA Container Orchestration Practice Question
In a container image built from a Dockerfile, what is the purpose of the CMD instruction?
⚠ Common exam trap
The KCNA exam often tests the distinction between CMD and RUN, where candidates mistakenly think CMD runs at build time, but the trap is that CMD only defines runtime defaults and is overridable, unlike RUN which executes during image creation.
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
✓
To provide default arguments for the ENTRYPOINT instruction
The CMD instruction in a Dockerfile provides default arguments for the ENTRYPOINT instruction when the container is run. If no ENTRYPOINT is defined, CMD itself serves as the default command to execute. This allows users to override the default behavior at runtime by appending arguments to `docker run`, which replace the CMD values while preserving the ENTRYPOINT.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
To specify a command that always runs at build time
Why it's wrong here
RUN executes commands at build time; CMD is for runtime.
- ✗
To copy files into the image
Why it's wrong here
COPY and ADD copy files.
- ✓
To provide default arguments for the ENTRYPOINT instruction
Why this is correct
CMD can provide default arguments to ENTRYPOINT, or be the main command if ENTRYPOINT is not set.
- ✗
To define environment variables
Why it's wrong here
ENV sets environment variables.
Go deeper
Related to this question
About these practice questions
This KCNA question is part of Courseiva's 833-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This KCNA practice question is part of Courseiva's free CNCF 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 KCNA exam.