Courseiva
Troubleshooting →easyMultiple Choice

CKA Troubleshooting Practice Question

To view the logs of a specific container in a multi-container pod named 'web-pod', which command is correct?

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 web-pod --container app-container

The correct command is 'kubectl logs web-pod -c app-container'. The -c flag specifies the container name.

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 web-pod --all-containers

    Why it's wrong here

    The --all-containers flag tells kubectl logs to stream output from every container in the pod, not a single named container. This would interleave logs from all containers, making it impossible to isolate the specific container's output. Since the goal is to inspect logs from one container only, this flag is inappropriate.

  • ✓

    kubectl logs web-pod --container app-container

    Why this is correct

    The kubectl logs command uses the --container (or shorthand -c) flag to select a specific container in a multi-container pod. Here, web-pod is the pod name and app-container is the container name, which is the exact syntax required. This command correctly returns only the logs from app-container, making it the right choice.

  • ✗

    kubectl logs app-container -p web-pod

    Why it's wrong here

    This command incorrectly places the container name as the first positional argument, but kubectl logs expects the pod name immediately after the subcommand. Additionally, -p is the shorthand for --previous, which shows logs from the previous incarnation of a container (e.g., after a crash or restart), not a way to specify a container. The container selector must be provided with -c/--container after the pod name.

  • ✗

    kubectl logs -c web-pod app-container

    Why it's wrong here

    Although -c is a valid shorthand for --container, the argument order is wrong: kubectl logs expects the pod name as the first positional argument, followed by the container flag and its value. In this command, kubectl would interpret web-pod as the container name and app-container as the pod name, looking for a pod named app-container with a container named web-pod. This will cause an error or return unexpected logs.

About these practice questions

One of 726 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.