Courseiva
Kubernetes FundamentalsmediumMultiple ChoiceObjective-mapped

KCNA Kubernetes Fundamentals Practice Question

Which command would you use to view the logs of a container named 'sidecar' inside a pod named 'app'?

⚠ Common exam trap

The trap is that candidates may assume the container name can be passed as a second positional argument instead of using the `-c` flag.

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 app -c sidecar

The `kubectl logs` command uses the `-c` flag to specify a container name within a pod. When a pod contains multiple containers, you must explicitly indicate which container's logs to retrieve. The syntax `kubectl logs <pod-name> -c <container-name>` is the standard way to view logs from a specific container in a multi-container pod.

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 app -c sidecar

    Why this is correct

    This command retrieves logs from the specified container.

  • kubectl logs app sidecar

    Why it's wrong here

    The correct syntax is `kubectl logs app -c sidecar`.

  • kubectl logs sidecar app

    Why it's wrong here

    The order and flags are wrong.

  • kubectl logs sidecar -p app

    Why it's wrong here

    The syntax is incorrect; `-p` is for previous instance.

About these practice questions

One of 833 original KCNA 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 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.