KCNA Kubernetes Fundamentals Practice Question
You need to inspect the logs of a container named 'app' in a pod called 'web-1'. Which kubectl command should you use?
⚠ Common exam trap
CNCF often tests the argument order of `kubectl logs` and the use of `-c` to specify a container. While `--container` is also a valid flag, the exam may expect the short flag `-c` when a single answer is required. Ensure the pod name comes before the container flag.
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
✓
kubectl logs web-1 -c app
The `kubectl logs` command uses the `-c` flag to specify a container within a multi-container pod. The pod name must be specified first, followed by the container flag. Option A uses the long form `--container`, which is also valid syntax, but this single-choice question expects the short flag `-c` as the standard answer. Option C incorrectly places the container name as the first argument (kubectl logs app web-1). Option D uses the `-p` flag, which is for viewing logs of a previous container instance, not for selecting a container by name.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl logs web-1 --container app
Why it's wrong here
Correct. The `--container` flag is the long-form alias for `-c` and is perfectly valid. The syntax `kubectl logs pod-name --container container-name` is correct.
- ✓
kubectl logs web-1 -c app
Why this is correct
Correct. The `-c` flag is the short form for `--container` and is the standard syntax shown in kubectl help. Both A and B are valid commands.
- ✗
kubectl logs app web-1
Why it's wrong here
Incorrect. The argument order is wrong: `kubectl logs` expects the pod name first, then optionally the container flag. Writing `kubectl logs app web-1` would attempt to treat 'app' as the pod name and 'web-1' as the container name, which is reversed.
- ✗
kubectl logs -p web-1 app
Why it's wrong here
Incorrect. The `-p` flag is used to view logs from a previous instance of a container (e.g., after a crash), not to specify a container within a multi-container pod. The correct syntax for specifying container is `-c` or `--container`.
Go deeper
Related to this question
About these practice questions
Courseiva writes every KCNA question from scratch — 930 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 KCNA 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 KCNA exam.