- A
The container runs as root because runAsUser overrides runAsNonRoot
Why wrong: Incorrect. The pod specifies both `runAsNonRoot: true` and `runAsUser: 1001`. This does not result in running as root. The `runAsNonRoot` constraint prevents root execution, and `runAsUser` sets the user to 1001.
- B
The container fails to start because it cannot run as root
Why wrong: Incorrect. The container will not fail to start because it is not attempting to run as root. The `runAsUser: 1001` overrides the image's default user, and since 1001 is non-root, the `runAsNonRoot` constraint is satisfied.
- C
The container runs as user 1001
Correct. The `runAsUser: 1001` directive overrides the container's default user, causing the container to run as UID 1001, which is non-root and satisfies the `runAsNonRoot` constraint.
- D
The pod runs, but the securityContext is ignored
Why wrong: Incorrect. The `securityContext` is not ignored. Both `runAsNonRoot` and `runAsUser` are applied; the container runs as the specified non-root user.
How runAsNonRoot and runAsUser Work Together in Pod SecurityContext
This CKS practice question tests your understanding of minimize microservice vulnerabilities. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. A key principle to apply: runAsNonRoot. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
A pod manifests with securityContext: { runAsNonRoot: true, runAsUser: 1001 }. However, the container image expects to run as root (UID 0). What will happen when the pod is created?
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
The container runs as user 1001
When `runAsNonRoot: true` is set, Kubernetes enforces that the container cannot run as root (UID 0). However, the pod also specifies `runAsUser: 1001`, which tells Kubernetes to run the container as UID 1001. Since UID 1001 is non-root, the `runAsNonRoot` constraint is satisfied. The container image's expectation to run as root is irrelevant because Kubernetes overrides the user with the specified `runAsUser`. Therefore, the container will start and run as user 1001.
Key principle: runAsNonRoot
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The container runs as root because runAsUser overrides runAsNonRoot
Why it's wrong here
Incorrect. The pod specifies both `runAsNonRoot: true` and `runAsUser: 1001`. This does not result in running as root. The `runAsNonRoot` constraint prevents root execution, and `runAsUser` sets the user to 1001.
- ✗
The container fails to start because it cannot run as root
Why it's wrong here
Incorrect. The container will not fail to start because it is not attempting to run as root. The `runAsUser: 1001` overrides the image's default user, and since 1001 is non-root, the `runAsNonRoot` constraint is satisfied.
- ✓
The container runs as user 1001
Why this is correct
Correct. The `runAsUser: 1001` directive overrides the container's default user, causing the container to run as UID 1001, which is non-root and satisfies the `runAsNonRoot` constraint.
Related concept
runAsNonRoot
- ✗
The pod runs, but the securityContext is ignored
Why it's wrong here
Incorrect. The `securityContext` is not ignored. Both `runAsNonRoot` and `runAsUser` are applied; the container runs as the specified non-root user.
Common exam traps
Common exam trap: answer the scenario, not the keyword
The trap is that candidates think `runAsNonRoot` alone blocks execution if the image expects root, but they overlook that `runAsUser` can override the image's user to a non-root UID. In this case, the container runs successfully as user 1001, not fails.
Detailed technical explanation
How to think about this question
Under the hood, the kubelet uses the `RunAsNonRoot` field in the PodSecurityContext to validate the container's user ID before starting the container. If the image's `USER` directive is set to root (UID 0) and `runAsNonRoot` is true, the container runtime (e.g., containerd) will reject the container creation. This is enforced by the `SecurityContext` validation in the kubelet's `PodSecurity` admission controller, which checks the effective UID against the `runAsNonRoot` constraint. A real-world scenario is when a container image built with a root default user is used in a cluster with a Pod Security Admission policy that enforces `restricted` level, causing the pod to fail to start.
KKey Concepts to Remember
- runAsNonRoot
- runAsUser
- Container SecurityContext
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
runAsNonRoot
Real-world example
How this comes up in practice
A practitioner preparing for the CKS exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. runAsNonRoot Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Review runAsNonRoot, then practise related CKS questions on the same topic to reinforce the concept.
- →
Minimize Microservice Vulnerabilities — study guide chapter
Learn the concepts, then practise the questions
- →
Minimize Microservice Vulnerabilities practice questions
Targeted practice on this topic area only
- →
All CKS questions
997 questions across all exam domains
- →
Certified Kubernetes Security Specialist CKS study guide
Full concept coverage aligned to exam objectives
- →
CKS practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related CKS practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Monitoring Logging and Runtime Security practice questions
Practise CKS questions linked to Monitoring Logging and Runtime Security.
Cluster Setup and Hardening practice questions
Practise CKS questions linked to Cluster Setup and Hardening.
System Hardening practice questions
Practise CKS questions linked to System Hardening.
Minimize Microservice Vulnerabilities practice questions
Practise CKS questions linked to Minimize Microservice Vulnerabilities.
Supply Chain Security practice questions
Practise CKS questions linked to Supply Chain Security.
Monitoring, Logging and Runtime Security practice questions
Practise CKS questions linked to Monitoring, Logging and Runtime Security.
Cluster Setup practice questions
Practise CKS questions linked to Cluster Setup.
Cluster Hardening practice questions
Practise CKS questions linked to Cluster Hardening.
CKS fundamentals practice questions
Practise CKS questions linked to CKS fundamentals.
CKS scenario practice questions
Practise CKS questions linked to CKS scenario.
CKS troubleshooting practice questions
Practise CKS questions linked to CKS troubleshooting.
Practice this exam
Start a free CKS practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this CKS question test?
Minimize Microservice Vulnerabilities — This question tests Minimize Microservice Vulnerabilities — runAsNonRoot.
What is the correct answer to this question?
The correct answer is: The container runs as user 1001 — When `runAsNonRoot: true` is set, Kubernetes enforces that the container cannot run as root (UID 0). However, the pod also specifies `runAsUser: 1001`, which tells Kubernetes to run the container as UID 1001. Since UID 1001 is non-root, the `runAsNonRoot` constraint is satisfied. The container image's expectation to run as root is irrelevant because Kubernetes overrides the user with the specified `runAsUser`. Therefore, the container will start and run as user 1001.
What should I do if I get this CKS question wrong?
Review runAsNonRoot, then practise related CKS questions on the same topic to reinforce the concept.
What is the key concept behind this question?
runAsNonRoot
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Keep practising
More CKS practice questions
- Which flag is used to restrict the kubelet's ability to modify node status and pods?
- A Falco rule has priority `WARNING` and output: `Sensitive file opened (user=%user.name command=%proc.cmdline file=%fd.n…
- Falco detects a shell being opened inside a container. Which Falco rule field is used to specify the syscall condition f…
- A security audit reveals that a ServiceAccount named 'monitor' has a ClusterRoleBinding to the cluster-admin role. What…
- Match each Kubernetes security component to its description.
- Match each Kubernetes certificate type to its usage.
Last reviewed: Jul 4, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.