Courseiva
Troubleshooting →easyMultiple Choice

CKA Troubleshooting Practice Question

Which command shows the logs of a pod that has crashed and restarted?

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

kubectl logs --previous shows logs from the previous container instance.

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 --previous

    Why this is correct

    The --previous flag retrieves log output from the previous terminated container instance. After a pod crashes and the container restarts, the newly started container starts with a fresh log file, so only --previous exposes the output from the failed run that triggered the restart. This is the standard way to diagnose why a container exited.

  • ✗

    kubectl logs pod-name

    Why it's wrong here

    Without --previous, kubectl logs pod-name displays only the logs from the currently running container instance. If the container has already crashed and been restarted, the original log output is no longer attached to the current container, so this command typically returns empty or only the short-lived new run's logs, making it insufficient for crash diagnosis.

  • ✗

    kubectl logs pod-name -c container-name

    Why it's wrong here

    The -c container-name flag lets you target logs from a specific container in a multi-container pod, but it does not change the underlying log source. It still reads the current container's live log stream; for a crashed and restarted container, you must combine -c with --previous to retrieve the old log output. Thus this command alone doesn't show the pre-crash logs.

  • ✗

    kubectl describe pod pod-name

    Why it's wrong here

    kubectl describe pod pod-name displays pod metadata, status, events, restart count, and last container termination reason, but it never outputs the actual content of container logs. It can tell you that the container has restarted (e.g., CrashLoopBackOff) and why the last termination occurred, but the log lines themselves are only accessible via kubectl logs. Therefore it is not a log-inspection command.

About these practice questions

Courseiva writes every CKA question from scratch — 726 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 →

How Courseiva writes practice questions · Editorial policy

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.