Courseiva

CKS Monitoring, Logging and Runtime Security Practice Question

An administrator wants to ensure that containers in the 'secure-app' namespace cannot write to their own filesystem. Which pod security context setting should be used?

⚠ Common exam trap

CKS often tests the confusion between capability dropping and filesystem immutability — candidates who pick capabilities: drop ALL miss that write access to the root filesystem is controlled by the mount flag, not by Linux capabilities.

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

✓

securityContext: { readOnlyRootFilesystem: true }

Setting readOnlyRootFilesystem: true mounts the container's root filesystem as read-only, preventing any process inside the container from writing to it. This directly satisfies the requirement that containers cannot write to their own filesystem. Writable volumes can still be mounted separately for legitimate write needs.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    securityContext: { runAsNonRoot: true }

    Why it's wrong here

    This setting enforces that the container process has a numeric user ID other than 0, either by using the image's user or causing a runtime error if the user is root. However, a non-root user with sufficient filesystem permissions (e.g., uid 1000 in a custom image) can still create, modify, or delete files in the container's writable layer. The root filesystem remains mounted read-write, so runAsNonRoot does not satisfy the requirement of a read-only filesystem.

  • ✗

    securityContext: { privileged: false }

    Why it's wrong here

    Setting privileged: false explicitly places the container in standard (non-privileged) mode — also the default — meaning the container cannot access host devices directly or gain extended Linux capabilities beyond the configured set. This reduces the attack surface but has no effect on how the root filesystem is mounted; the container can still write to its writable layer. It is neither a privilege-escalation control nor a filesystem-mount option, so it does not establish read-only behavior.

  • ✗

    securityContext: { capabilities: { drop: ["ALL"] } }

    Why it's wrong here

    Dropping all capabilities removes kernel privileges such as CAP_NET_BIND_SERVICE, CAP_CHOWN, or CAP_DAC_OVERRIDE, which limits certain privileged operations, but writes to a container's filesystem are governed by filesystem permissions, mount options, and UID mappings rather than the capability set alone. If the container runs as root and the root filesystem is writable, dropping capabilities may still allow file modifications depending on the exact image layer permissions and user namespace configuration. The writable mount remains unchanged, so this option does not enforce a read-only root filesystem.

  • ✓

    securityContext: { readOnlyRootFilesystem: true }

    Why this is correct

    Setting readOnlyRootFilesystem: true causes the container runtime to mount the container's root filesystem as read-only, so the write layer is not writable from the container's perspective; any attempt to modify an existing file or create a new file in the root directory tree will fail with EROFS. This directly prevents an attacker who compromises the container from persisting changes in the container layer, though ephemeral writes can still be accommodated by mounting volumes (e.g., emptyDir) at specific paths such as /tmp. It is the only option among those listed that enforces the filesystem-level read-only requirement.

About these practice questions

Courseiva writes every CKS question from scratch — 845 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CNCF exam blueprint

This CKS 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 CKS exam.