nerdexam
Linux_Foundation

KCNA · Question #56

Which of the following will view the snapshot of previously terminated ruby container logs from Pod web-1?

The correct answer is A. kubectl logs -p -c ruby web-1. To view logs from a previously terminated container within a Kubernetes Pod, use kubectl logs with the -p (previous) flag and specify the container with -c.

Submitted by marco_it· May 4, 2026Cloud Native Observability

Question

Which of the following will view the snapshot of previously terminated ruby container logs from Pod web-1?

Options

  • Akubectl logs -p -c ruby web-1
  • Ckubectl logs -p ruby web-1
  • Dkubectl logs -p -c web-1 ruby

How the community answered

(62 responses)
  • A
    94% (58)
  • C
    2% (1)
  • D
    5% (3)

Why each option

To view logs from a previously terminated container within a Kubernetes Pod, use `kubectl logs` with the `-p` (previous) flag and specify the container with `-c`.

Akubectl logs -p -c ruby web-1Correct

The `kubectl logs` command with the `-p` (or `--previous`) flag is used to retrieve logs from a previous instantiation of a container. The `-c` (or `--container`) flag specifies the container name within the Pod from which to retrieve logs, and `web-1` is the Pod name.

Ckubectl logs -p ruby web-1

This command is missing the `-c` flag to specify the container name. `ruby` would be interpreted as part of the Pod name or an invalid argument without `-c`.

Dkubectl logs -p -c web-1 ruby

The order of arguments is incorrect; the container name (`ruby`) should follow the `-c` flag, and the Pod name (`web-1`) should be the primary argument.

Concept tested: `kubectl logs` previous container

Source: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources

Topics

#kubectl#logs#containers#observability

Community Discussion

No community discussion yet for this question.

Full KCNA Practice