Courseiva
Container Orchestration →easyMultiple Choice

KCNA Container Orchestration Practice Question

Which command would you use to view the logs of a specific container in a pod?

⚠ Common exam trap

It's easy for candidates to assume `kubectl logs <pod-name>` works universally, forgetting that multi-container pods require the `-c` flag to specify the container, which Kubernetes frequently tests to assess understanding of pod-level vs. container-level operations.

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> -c <container-name>

`kubectl logs <pod-name> -c <container-name>` explicitly targets a specific container within a pod. In Kubernetes, a pod can host multiple containers, and without the `-c` flag, `kubectl logs` defaults to the first container in the pod spec, which may not be the intended one. This command is essential for multi-container pods where each container has its own log stream.

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

    Without the -c flag, kubectl logs returns output only from the pod's single container, or errors when multiple containers exist. It is tempting because it is the correct base command for log retrieval, and would suffice for a single-container pod where no container needs naming.

  • ✗

    kubectl logs <container-name>

    Why it's wrong here

    kubectl logs requires the pod name, optionally with -c for a specific container; a bare container name alone is not a valid target. It tempts because container names appear in the command's -c flag, but the pod must be named first for kubectl to locate the logs.

  • ✓

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

    Why this is correct

    The -c flag scopes log retrieval to the named container within a multi-container pod, which is the constraint the stem implies. Without it, kubectl logs defaults to the pod's first container, returning the wrong output.

  • ✗

    kubectl describe pod <pod-name>

    Why it's wrong here

    kubectl describe reports pod metadata, events and container status, not the stdout/stderr stream the question asks for. It is tempting because it surfaces container state and restart reasons, which is the right choice when diagnosing why a container failed to start rather than reading its logs.

About these practice questions

Courseiva writes every KCNA question from scratch — 930 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 KCNA 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 KCNA exam.