non-root user
An ordinary user account with limited rights, which a container should run its service as.
In more detail
Create one in the Dockerfile and switch with USER. The service can then only write where you allow, which limits the damage from a bug or an attack. Ports below 1024 and some file permissions need adjusting, which is a small price.
Examples
USER nonroot:nonrootUSER 10001RUN adduser --system --uid 1001 nextjs
USER nextjsUSER app in the Dockerfile, UID 10001 at run timeRelated terms
- USER — The Dockerfile instruction that sets which user later instructions and the container run as.
- root user — The all-powerful administrator account on Linux, with user ID 0, which can read or change anything.
- least privilege — Giving every program and person only the access they need, and nothing more.
- file permissions — Rules on each file saying which user and group own it and who may read, write or run it.
- attack surface — Everything an attacker could try to use against a system: open ports, installed programs, accounts and settings.
- container — A running program that has been fenced off from the rest of the computer so it only sees its own files, network and processes.
- UID and GID — The numbers Linux uses to identify a user (UID) and a group (GID); root is UID 0.
Taught in
- Container Images The Exam Way — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Design And Build: Timed Drill And Checkpoint — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Minimal Base Images: Less To Attack — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Immutable Containers: Read-Only At Runtime — 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
- FROM, WORKDIR, COPY And ADD — Docker Architecture & Production Containers
- CMD, ENTRYPOINT, USER And Process Signals — Docker Architecture & Production Containers
- Multi Stage Builds, Targets And Build Secrets — Docker Architecture & Production Containers
- Minimal Bases, Non Root Users And Smaller Images — Docker Architecture & Production Containers
- Ephemeral Filesystems And Named Volumes — Docker Architecture & Production Containers
- Bind Mounts, Permissions And Backups — Docker Architecture & Production Containers
- Environment, Secret Files And Runtime Restrictions — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers
- Containerization Architecture: Multi-Stage Dockerfiles — Production Full-Stack Engineering
- Shipping in Scratch and Distroless Images — Concurrent Systems Programming with Go
- Packaging Into A Container — Modern Java: Virtual Threads & High-Throughput Services
- securityContext: Nonroot, Capabilities And Seccomp — Kubernetes: Production-Grade Container Orchestration
- Pod Security Admission And Pod Security Standards — Kubernetes: Production-Grade Container Orchestration
- Containerized Deployment: Multi-Stage Docker Builds — Next.js 15 & Modern App Router Architecture
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services
- Container Security: Minimal Bases And Non Root — Application Security & Threat Modeling for Engineers
References
- Dockerfile reference: USER
- OWASP Docker Security Cheat Sheet
- Docker Docs: Dockerfile best practices (USER)
- Dockerfile reference
- Docker docs: Multi-stage builds