XK0-006 Automation, Orchestration, and Scripting Practice Question
An administrator is debugging a Docker container that exits immediately after starting. Which THREE commands can help diagnose the issue? (Select THREE).
⚠ Common exam trap
The trap here is that candidates may select docker exec or docker ps, but exec requires a running container, and ps without -a does not show exited containers; the exam tests knowledge of which commands work on stopped containers.
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 --rm -it <image> sh
Option A (docker run --rm -it <image> sh) is correct because it overrides the image's default entrypoint/command with an interactive shell, letting you explore the filesystem and manually run the failing process to see errors directly. Option B (docker logs <container>) is correct because it retrieves stdout/stderr captured from the container's main process, which typically contains the crash message or stack trace explaining the immediate exit. Option C (docker inspect <container>) is correct because it reveals the container's ExitCode, State, Error, and the configured Entrypoint/Cmd, helping identify misconfigurations or non-zero exit reasons. Option D (docker exec -it <container> sh) does not belong because exec requires a running container, and this container has already exited. Option E (docker ps) does not belong because it only lists running containers by default, so the exited container would not appear unless -a is used, and it provides no diagnostic detail.
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 --rm -it <image> sh
Why this is correct
Overriding the image's default entrypoint with an interactive shell keeps the container running and exposes its filesystem, letting you inspect why the original command exited. This directly addresses the immediate-exit symptom by bypassing the failing startup command.
- ✓
docker logs <container>
Why this is correct
`docker logs <container>` retrieves stdout and stderr captured from the container's main process, revealing crash messages, stack traces or configuration errors emitted before exit. For a container that terminates immediately, this output is the primary diagnostic record, directly satisfying the stem's need to identify why the process failed at startup.
- ✓
docker inspect <container>
Why this is correct
docker inspect returns the container's exit code, state, and configuration, revealing whether the process failed due to a bad command, missing environment variable, or non-zero exit. This exposes the root cause behind the immediate termination.
- ✗
docker exec -it <container> sh
Why it's wrong here
docker exec requires a running container, so it cannot be used once the container has already exited; there is no process to attach to. It is tempting because it is the standard way to inspect a live container's filesystem and processes, which would be correct had the container stayed up.
- ✗
docker ps
Why it's wrong here
docker ps lists only running containers by default, so an exited container will not appear, hiding the very state being diagnosed. It is tempting because it is the first command used to check container status, and adding -a would correctly reveal stopped containers.
Go deeper
Related to this question
Learn chapter
Advanced Shell Scripting and Automation
Key term
Process
In IT service management, a process is a structured set of activities designed to accomplish a specific objective, such as managing incidents or changes, by transforming inputs into defined outputs.
Key term
Shell
A shell is a computer program that provides a user interface to access an operating system's services, typically by accepting text commands.
About these practice questions
This XK0-006 question is part of Courseiva's 781-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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
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.