runAsNonRoot
A Kubernetes security setting that, when set to true, stops a container from starting if it would run as the root user.
In more detail
The kubelet checks which user the container would run as and refuses to start it if that is user 0, root. It can only check a numeric user, so the image must name its user by number, such as 65532, or runAsUser must be set to a non-zero number. The restricted Pod Security Standard requires it to be true, set for the whole pod or on each container.
Examples
securityContext:
runAsNonRoot: truesecurityContext:
runAsNonRoot: true
runAsUser: 10001("runAsNonRoot true", get("runAsNonRoot") is True)Related terms
- securityContext — The part of a Kubernetes pod or container spec that sets security options such as user, capabilities, seccomp and read-only root filesystem.
- non-root user — An ordinary user account with limited rights, which a container should run its service as.
- Pod Security Standards — Three built-in Kubernetes security profiles, called privileged, baseline and restricted, that define how locked down a pod must be.
- root user — The all-powerful administrator account on Linux, with user ID 0, which can read or change anything.
Taught in
- SecurityContexts And Capabilities — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Configuration And Security: Timed Drill And Checkpoint — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Mock Exam: Sixteen Tasks Against The Clock — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Pod Security Admission: Created, Never Started — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Static Analysis: kubesec And KubeLinter — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Immutable Containers: Read-Only At Runtime — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Mock Exam: Seventeen Security Tasks Against The Clock — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Container Hardening: Distroless & Rootless — Cloud Security & DevSecOps Engineering
- Kubernetes Pod Security Standards: Baseline & Restricted — Cloud Security & DevSecOps Engineering
- Security Frameworks: NIST CSF 2.0, ISO 27001 & CIS — Cybersecurity Fundamentals, GRC & Cryptography
- A Pod That Mounts The Node: Runtime, Pods And Storage — Kubernetes and Cloud Native Security Associate (KCSA) Exam Prep
- securityContext: Nonroot, Capabilities And Seccomp — Kubernetes: Production-Grade Container Orchestration