CKAD Application Design and Build Practice Question
Which Dockerfile instruction sets a default command that can be overridden by arguments passed to 'docker run'?
⚠ Common exam trap
The CKAD exam often tests the distinction between CMD and ENTRYPOINT, and the trap here is that candidates confuse CMD (which can be overridden) with ENTRYPOINT (which requires the --entrypoint flag to override), leading them to incorrectly select ENTRYPOINT as the instruction that accepts overrides from 'docker run'.
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
✓
CMD
The CMD instruction in a Dockerfile sets a default command that runs when a container starts. This default can be overridden by providing arguments directly to 'docker run' after the image name, making it the correct choice for a command that is intended to be easily replaced.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ENTRYPOINT
Why it's wrong here
ENTRYPOINT defines the executable that runs when the container starts, effectively fixing the command that executes. It is not easily overridden because a `docker run` command-line argument is appended as arguments to the ENTRYPOINT, rather than replacing it; overriding it requires the explicit `--entrypoint` flag. This makes it unsuitable for a default command that can be routinely overridden.
- ✗
EXPOSE
Why it's wrong here
EXPOSE is a metadata instruction that records which network ports the container is expected to listen on, purely for documentation and image inspection. It does not modify the filesystem, set a runtime process, or specify any command to run when the container starts. Consequently, it has no relationship to a container's default command and cannot satisfy the requirement of being overridden at runtime.
- ✓
CMD
Why this is correct
The CMD instruction specifies a default command and optional parameters that Docker executes when the container starts, providing a baseline behavior for the image. It is designed to be overridden easily: when you run the container and supply your own command-line arguments, they replace the CMD entirely. Thus CMD precisely matches the requirement of setting a default command that can be overridden.
- ✗
RUN
Why it's wrong here
RUN executes a command in a new layer on top of the current image during the build process, installing packages or modifying files, and commits the result into the resulting image. It is a build-time operation that never runs at container runtime, so it cannot define the default command that starts the container. Therefore it is incorrect for this question.
Go deeper
Related to this question
About these practice questions
This CKAD question is part of Courseiva's 826-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 CKAD 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 CKAD exam.