CKA kubectl logs --previous Practice Question
A pod has been restarted multiple times. You want to see the logs from the previous (terminated) container instance. Which command should you use?
⚠ Common exam trap
Candidates often confuse the shorthand `-p` (for `--previous`) with other flags like `-c` (which specifies a container name) or assume that a longer, incorrect flag like `--past` or `--prev` is the correct syntax.
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 my-pod -p
The `kubectl logs` command retrieves logs for a container in a pod. To view the logs of a previously terminated container instance, you must use either the `--previous` or `-p` flag. To ensure there is only one correct option, we will change Option D to use an invalid flag (`--past`), leaving Option C (`-p`) as the sole correct answer.
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 my-pod -c --previous
Why it's wrong here
Incorrect: The `-c` flag requires a container name, and `--previous` is not properly combined. This command would fail.
- ✗
kubectl logs my-pod --tail=100
Why it's wrong here
Incorrect: `--tail=100` limits the output to the last 100 lines of the current logs, not from the previous instance.
- ✓
kubectl logs my-pod -p
Why this is correct
Correct: The `-p` flag is a valid shorthand for `--previous` in `kubectl logs`, so this command retrieves logs from the previous terminated container instance.
- ✗
kubectl logs my-pod --past
Why it's wrong here
Correct: `--previous` explicitly retrieves logs from the previous terminated container instance.
Go deeper
Related to this question
Learn chapter
Configuring Scheduling and Affinity
Key term
Log Analysis
Log analysis is the process of reviewing and interpreting system-generated records to understand what happened in an application or infrastructure.
Key term
kubectl Command Reference
kubectl is the command-line tool used to interact with and manage Kubernetes clusters by sending commands to the Kubernetes API.
About these practice questions
This CKA question is part of Courseiva's 302-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 CKA 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 CKA exam.