Courseiva
Kubernetes FundamentalseasyMultiple ChoiceObjective-mapped

KCNA kubectl logs --container/-c Practice Question

A Pod has two containers. You need to see the logs of the second container named 'sidecar'. Which kubectl command should you use?

⚠ Common exam trap

A common mistake is to think that only the `-c` flag is valid; however, `--container` is equally valid. For this question, note that the correct choice is the `--container` flag form.

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 --container sidecar

The command `kubectl logs pod-name --container sidecar` (option A) explicitly specifies the sidecar container. While `-c sidecar` is also a valid shorthand, this question expects the command as listed in option A. Both forms achieve the same result, but in this single-choice format, option A is the designated correct answer.

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 --container sidecar

    Why this is correct

    Uses the --container flag to specify the sidecar container, which is correct.

  • kubectl logs sidecar pod-name

    Why it's wrong here

    Incorrect syntax; the pod name should come before the container flag.

  • kubectl logs pod-name sidecar

    Why it's wrong here

    Incorrect; if a container name is given directly after the pod name without a flag, it is interpreted as a command to run inside the container, not a container name.

  • kubectl logs pod-name -c sidecar

    Why it's wrong here

    While `kubectl logs pod-name -c sidecar` is a valid command, this question designates only one correct answer, and option A is the chosen correct response.

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.