How do you verify that an image has a non-root user before deploying?
BeginnerProductionImage Security & Hardening
Answer
docker image inspect -f '{{.Config.User}}' app:1.4.2 # empty = root
docker run --rm --entrypoint id app:1.4.2
Automate with Trivy config scan (rule DS002 "image should not run as root"), Hadolint, or a Kyverno policy.
More on Image Security & Hardening
Why should containers not run as root, and how do you enforce it?BeginnerWhat is a distroless image and what are the trade-offs?BeginnerHow do you scan an image with Trivy and fail a CI build on serious findings?BeginnerHow do you manage Trivy false positives and accepted risks?IntermediateWhich `docker run` flags make up a hardened runtime baseline?BeginnerWhat does `no-new-privileges` protect against?Beginner