Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

Which Dockerfile instruction sets the command to run when the container starts, but allows the user to override it when using 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

CMD provides defaults for an executing container. If CMD is used, it can be overridden by command-line arguments to docker run. ENTRYPOINT, on the other hand, is not easily overridden without --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.

  • ✗

    RUN

    Why it's wrong here

    RUN executes commands during image build, committing the results as a new layer; it has no effect on what starts when the container launches. It is tempting because it runs a command, but it would be correct for installing packages or compiling software at build time, whereas CMD supplies the overridable runtime command.

  • ✗

    STARTUP

    Why it's wrong here

    STARTUP is not a valid Dockerfile instruction, so the build fails rather than setting a container command. It is tempting because the name suggests initialisation behaviour, but the correct instruction for a default, overridable start command is CMD, which docker run arguments replace; ENTRYPOINT sets a non-overridable executable.

  • ✗

    ENTRYPOINT

    Why it's wrong here

    ENTRYPOINT defines the fixed executable, so docker run arguments are appended as parameters rather than replacing it; overriding requires --entrypoint. It is tempting because ENTRYPOINT suits containers that must always run one specific process, such as a database daemon, where CMD supplies only default arguments.

  • ✓

    CMD

    Why this is correct

    CMD sets the default command executed when the container starts, but it is overridden when arguments are supplied to docker run. ENTRYPOINT, by contrast, is not overridden this way, so CMD matches the stated requirement.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 781 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 →

How Courseiva writes practice questions · Editorial policy

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.