CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Administrator

securityContext and Non-Root Containers

Containers run as root unless you say otherwise. Set a non-root user, drop every capability, make the root filesystem read-only, and then find out which of those settings produced the error when a write fails.

Configuration and Secrets Guide 37 of 103 Intermediate

UID values are arbitrary choices. The enforcement behaviour is not.

Any cluster does. Run against the four-node lab.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

This guide includes

Use this when a container should not be running as root - which it is, unless something says otherwise. This matters because several securityContext settings overlap, and knowing which one actually refused a write is the difference between fixing it and guessing at it.

Before you start

  1. The default is root, and that is the problem

  2. Confirm who it is

  3. Which setting actually blocked the write?

  4. Clean up

Official sources