CKAD Application Design and Build Practice Question
Which of the following Dockerfile instructions is used to set a command that runs when the container starts and can be overridden by command-line arguments?
⚠ Common exam trap
In the CKAD exam, candidates often confuse CMD with ENTRYPOINT. CMD provides default command that can be overridden by command-line arguments, whereas ENTRYPOINT specifies the executable that runs when the container starts and is not overridden unless --entrypoint flag is used.
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 provides default command(s) for the executing container. When a user runs `docker run image [COMMAND]`, the provided COMMAND overrides the CMD value, making it the correct choice for a command that can be overridden by command-line arguments.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
EXPOSE
Why it's wrong here
EXPOSE is a metadata instruction that declares which ports the container will listen on at runtime, but it does not expose or publish those ports to the host, nor does it start any process. It is purely informational, allowing users and orchestration tools to know the intended ports for port mapping. Since the question asks for the instruction that sets the startup command, EXPOSE is incorrect because it has no effect on the container's execution behavior.
- ✓
CMD
Why this is correct
CMD defines the default command and parameters that are executed when a container is started from the image, making it the primary instruction for specifying the main process. It can be overridden by additional arguments passed to `docker run`, and it works together with ENTRYPOINT, where CMD provides default arguments to the entrypoint. Unlike RUN, CMD is not executed during the image build; it is stored in the image as metadata and executed at runtime.
- ✗
COPY
Why it's wrong here
COPY is a build-time instruction that copies files or directories from the build context into the image's filesystem, providing the necessary artifacts for an application. It does not define or influence the container's startup command; it simply places files on disk that might be used by the process specified by CMD or ENTRYPOINT. This makes COPY incorrect for setting the startup command because it is purely a file operation, not a process definition.
- ✗
RUN
Why it's wrong here
RUN executes commands during the image build process, creating new layers in the filesystem by installing packages, modifying configuration, or compiling code. Whatever changes RUN makes are committed to the image, but these commands are never re-executed when a container starts; they are only for preparing the image. Since the container's startup command determines the main process at `docker run`, RUN cannot serve that purpose because it runs at build time, not at container start.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CKAD question from scratch — 826 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.