XK0-006 Automation, Orchestration, and Scripting Practice Question
A developer wants to view the logs from a running Docker container named 'myapp'. Which docker command should be used?
⚠ Common exam trap
The trap is confusing 'docker logs' with 'docker exec' or 'docker inspect'; candidates might think they need to enter the container to view logs, but Docker provides a direct command for that.
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 logs myapp
The 'docker logs' command is specifically designed to fetch the logs from a container's stdout/stderr. Running 'docker logs myapp' will display the logs generated by the container named 'myapp'. This is the standard and correct way to view container logs.
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 logs myapp
Why this is correct
docker logs retrieves stdout and stderr captured from the container's main process, and naming the container filters output to that instance. This satisfies the requirement to view logs from the running container 'myapp' without attaching to or executing inside it.
- ✗
docker ps myapp
Why it's wrong here
'docker ps' lists running containers and accepts no container name as a log source; it only filters by status or name via flags such as --filter. Logs come from 'docker logs myapp', which reads the container's stdout/stderr stream. 'docker ps' is correct when you need to confirm which containers are currently running.
- ✗
docker exec myapp logs
Why it's wrong here
'docker exec' runs a new process inside the container, so 'logs' would be treated as an executable name and fail unless such a binary exists. Container log output is retrieved by 'docker logs myapp', which reads the captured stdout/stderr stream. 'docker exec' suits running shell commands or diagnostics inside a live container.
- ✗
docker inspect myapp
Why it's wrong here
'docker inspect' returns container configuration and state as JSON, including mounts, networks and exit codes, but not the application's stdout/stderr log content. 'docker logs myapp' retrieves that captured output. 'docker inspect' is the right choice when you need metadata such as IP address, volume mappings or restart policy.
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 →
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.