CKA Troubleshooting Practice Question
Which kubectl command is used to view the logs of a container that has previously crashed in a pod?
⚠ Common exam trap
Candidates often assume `kubectl logs` without flags or with `--tail` will show crash logs, but they only see the current container's logs, missing the critical error from the previous crashed instance.
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 pod-name --previous
The `--previous` flag in `kubectl logs` retrieves logs from the previous instance of a container that has crashed and been restarted. This is essential for debugging crash loops, as the current container may have no logs or only startup logs, while the crashed container's logs contain the error.
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 pod-name -c container-name --tail=100
Why it's wrong here
This tails the last 100 lines of the current log, not the previous crash logs.
- ✗
kubectl logs pod-name --all-containers
Why it's wrong here
This shows logs from all containers, but not necessarily previous crash logs.
- ✓
kubectl logs pod-name --previous
Why this is correct
Correct. The --previous flag retrieves logs from the previous instance of the container.
- ✗
kubectl logs pod-name
Why it's wrong here
This shows current logs, not previous crash logs.
Go deeper
Related to this question
Learn chapter
Troubleshooting Storage Persistence
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
Courseiva writes every CKA question from scratch — 302 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 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.