DevOpsInterviewPrep logo
← ☸️ Containers & Kubernetes
Foundational

OpenShift arbitrary UIDs and writable paths: make the image fit the execution contract

Design an image that works with OpenShift-assigned user IDs. Inspect writable directories and mounted volumes without granting broad execution privileges to hide a filesystem defect.

TL;DR: A container admitted under an OpenShift security constraint can still fail because its process cannot write required files. Make only the intended paths writable for the permitted execution identity, and test mounted-volume permissions separately from image-layer permissions.

Admission and filesystem access are different failures

An SCC rejection happens before the Pod's requested execution settings are accepted. A process-level Permission denied after startup means the container reached a later boundary. Read events and container state first; looking only at the same application's previous admission failure can send the investigation to the wrong control.

OpenShift's default model commonly assigns a UID from the project's permitted range. Images that require a single hardcoded UID can fail even when their executable is readable. Red Hat's image guidelines describe supporting arbitrary user IDs and limiting writable paths.

rendering diagram…

Inventory the writes before changing permissions

In this teaching case, an application writes a PID file under /opt/app/run and a cache under /opt/app/cache. The image gives only UID 1000 write access. Under the permitted arbitrary UID, the process starts and fails on its first write.

Make those specific runtime directories compatible with the intended group permissions, or relocate temporary state into an appropriate writable volume. The documented image pattern uses root-group ownership with group permissions matching the owner's permissions for selected writable paths. Membership in group 0 does not itself make a process UID 0 or grant all root capabilities. Still avoid giving that group write access to application code, executables or sensitive configuration.

PathDesired accessReview question
Application binaryRead/executeCan the runtime alter its own executable?
Runtime PID/cache directoryScoped writeDoes the actual UID/group combination work?
Secret mountRead only where possibleCan it be copied into logs or artifacts?
Persistent data volumeWorkload-specific accessDoes storage ownership match the mount's policy?

A mount replaces the image's view of a path

Changing ownership in a Dockerfile does not fix every volume mounted over the same directory. At runtime, that mount supplies another filesystem with its own ownership and permissions. Inspect the actual mounted path, storage class, security context and supported group-ownership behavior.

Likewise, setting readOnlyRootFilesystem deliberately prevents writes to image-layer paths even when Unix permission bits would otherwise permit them. Keep the root filesystem read-only where the application supports it and supply explicit writable locations for its required temporary state. Verify startup, normal operation and shutdown; some programs write only during rotation or termination.

Test an image with representative permitted UIDs in an authorized container environment, then test it under the real SCC and volume configuration in a disposable project. A local container run validates filesystem assumptions but does not reproduce SCC admission or storage-driver behavior.

Self-check: the Pod is Running, logs show a cache-directory permission error, and granting anyuid would let the image use its built-in UID. Is that the preferred repair? Usually adapt the writable-path contract first. A broader UID exception needs a specific justified requirement, not merely a way to conceal a fixable image defect.

Practice the running Pod with a write failure after the OpenShift architecture overview.

RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS