Kubernetes YAML Cheat Sheet/Container securityContext

Drop privileges and run as non-root.

Section: Probes and Resources

Container securityContext

yaml
yaml
securityContext:
  runAsNonRoot: true
  runAsUser: 10001
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Probes and Resources
HTTP liveness, readiness, and startup probes
Use health checks to control traffic and restarts.
OpenIn sheetyamlsame section
CPU and memory requests/limits
Define scheduler reservations and hard caps.
OpenIn sheetyamlsame section
Minimal Pod manifest
Smallest practical Pod YAML shape.
Labels and annotations example
Common metadata block for selectors and tooling.
Override container command and args
Set entrypoint-style command in YAML.
Basic Deployment YAML
Run a replicated stateless workload.