Courseiva
Kubernetes FundamentalsmediumMultiple ChoiceObjective-mapped

KCNA kubectl logs Practice Question

You want to view the logs of a container named 'app' inside a pod named 'web-pod-7d4f8'. Which kubectl command should you use?

⚠ Common exam trap

In the KCNA exam, candidates often confuse 'kubectl logs' with 'kubectl exec' or use incorrect flag syntax (e.g., '--container' vs '-c'). Option C is the only correct syntax because 'kubectl logs' requires the pod name and optionally '-c' for container name.

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

The `kubectl logs` command is the standard way to retrieve container logs in Kubernetes. The `-c` flag specifies the container name within the pod, which is necessary when a pod contains multiple containers. Here, the container is named 'app' inside the pod 'web-pod-7d4f8', so `kubectl logs web-pod-7d4f8 -c app` correctly fetches its logs.

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 exec web-pod-7d4f8 -c app -- logs

    Why it's wrong here

    kubectl exec is for running commands inside a container, not for fetching logs.

  • kubectl log web-pod-7d4f8 --container app

    Why it's wrong here

    The command is 'kubectl logs', not 'kubectl log'.

  • kubectl logs web-pod-7d4f8 -c app

    Why this is correct

    This is the correct command to view logs of a specific container in a pod.

  • kubectl logs web-pod-7d4f8 app

    Why it's wrong here

    The correct syntax requires the -c flag before the container name: 'kubectl logs web-pod-7d4f8 -c app'.

About these practice questions

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