easyMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A developer wants to run a container with a…
A developer wants to run a container with a specific command that overrides the default entrypoint. Which Docker command should be used?
⚠ Common exam trap
Watch out — candidates often confuse `docker run` with `docker exec` or assume that appending a command after the image name (as in option A) overrides the entrypoint, when in fact it only overrides the CMD unless the entrypoint is explicitly changed with `--entrypoint`.
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
✓
docker run --entrypoint /bin/bash myimage
The `--entrypoint` flag in `docker run` allows you to override the default entrypoint defined in the Docker image. By specifying `--entrypoint /bin/bash`, the container will start with `/bin/bash` as its entrypoint, ignoring any `ENTRYPOINT` or `CMD` instructions in the Dockerfile. This is the standard Docker syntax for replacing the entrypoint at runtime.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
docker run myimage /bin/bash
Why it's wrong here
Only overrides CMD, not ENTRYPOINT.
- ✗
docker exec myimage /bin/bash
Why it's wrong here
Runs in existing container.
- ✓
docker run --entrypoint /bin/bash myimage
Why this is correct
Overrides ENTRYPOINT.
- ✗
docker start myimage /bin/bash
Why it's wrong here
start does not accept command.
Go deeper
Related to this question
About these practice questions
This XK0-006 question is part of Courseiva's 979-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 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.