How do you make sure an image runs on OpenShift or other random-UID platforms?
IntermediateProductionImage Security & Hardening
Answer
OpenShift runs containers with a random UID in group 0. Make writable directories group-writable and owned by root group: chgrp -R 0 /app/data && chmod -R g=u /app/data, avoid writing to the home directory, don't depend on a specific UID in /etc/passwd, and listen on ports above 1024.
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