Courseiva
Troubleshooting →easyMultiple Choice

CKA Troubleshooting Practice Question

You have a pod that is in 'CrashLoopBackOff' state. Which command should you use to view the logs from the previous instance of the container?

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 correct option is A, `kubectl logs pod-name --previous`, because when a container is in CrashLoopBackOff the current container instance may not have started or may have already been replaced, so the `--previous` (or `-p`) flag retrieves the logs from the last terminated instance of that container in the pod. This is the standard way to inspect why the container crashed on its prior run. Option D, `kubectl logs pod-name`, only shows logs from the currently running container instance, which may be empty or unavailable during a crash loop. Option B, `kubectl get events`, shows cluster-level event messages but not the container's stdout/stderr logs, and option C, `kubectl describe pod pod-name`, shows pod status, conditions, and recent events but not the previous container's application 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.

  • ✓

    kubectl logs pod-name --previous

    Why this is correct

    `kubectl logs pod-name --previous` correctly retrieves the logs from the last terminated container instance in the pod. Because CrashLoopBackOff means the container keeps crashing and restarting, the logs from the most recent crashed instance contain the panic, exception, or startup failure that caused the crash. The `--previous` flag explicitly tells the kubelet to read the terminated container's log file, which is exactly what you need to inspect when the current container has already restarted.

  • ✗

    kubectl get events

    Why it's wrong here

    `kubectl get events` surfaces cluster-scoped lifecycle events like image pulls, container starts, and back-off notifications from the kubelet, but it does not contain the container's stdout/stderr output. While an event may indicate the crash reason (e.g., 'Back-off restarting failed container'), the actual application error trace is in the container log. You need log output, not event metadata, to diagnose the root cause of the crash loop.

  • ✗

    kubectl describe pod pod-name

    Why it's wrong here

    `kubectl describe pod pod-name` provides a comprehensive summary of the pod—its spec, status, restart count, container state, and a list of recent events—but it does not show the container's captured log output. The describe output may include the termination reason (like `Error` or `OOMKilled`), but not the application-level exception stack or error message. This makes it useful for context, but insufficient for pulling the actual crash logs.

  • ✗

    kubectl logs pod-name

    Why it's wrong here

    `kubectl logs pod-name` without the `--previous` flag fetches logs from the currently running container instance. In a CrashLoopBackOff state, the current instance has either just started or has not yet produced output, so the command typically returns nothing or a minimal fragment. The fatal error from the last crashed instance is stored in the terminated container's log, which is ignored without the flag, making this command incomplete.

About these practice questions

This CKA question is part of Courseiva's 726-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 →

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.