Courseiva
TroubleshootingeasyMultiple ChoiceObjective-mapped

CKA Troubleshooting Practice Question

Which command should you use to view the logs of a container that has previously crashed in a Pod?

⚠ Common exam trap

Many exam-takers assume `kubectl logs <pod-name>` alone will show crash logs, but it only shows the current container's logs, so they miss the `--previous` flag required for accessing logs from a terminated 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

`kubectl logs <pod-name> --previous` retrieves the logs from the previous instance of a container in a Pod, which is exactly what you need when a container has crashed and restarted. The `--previous` flag accesses the logs of the terminated (crashed) container, not the current running one, allowing you to see the error that caused the crash.

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>

    Why it's wrong here

    This shows current logs, not previous ones.

  • kubectl describe pod <pod-name>

    Why it's wrong here

    kubectl describe shows events and status, not container logs.

  • kubectl logs <pod-name> -c <container-name>

    Why it's wrong here

    This command retrieves the logs from the *current* instance of the specified container, failing to address the requirement for logs from a *previously crashed* container. When a container crashes and restarts, its prior log stream is typically lost from the default `kubectl logs` output. It is tempting because `kubectl logs` is the standard method for viewing container output, and `-c` correctly targets a specific container within a multi-container pod. This option would be the correct choice for viewing the *current* logs of a running container.

  • kubectl logs <pod-name> --previous

    Why this is correct

    The --previous flag retrieves logs from the terminated container instance.

About these practice questions

One of 302 original CKA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.