September 19, 2018 · openshift Docker kubernetes

Allow containers to run as root on Openshift 3.10

Yes, I know that it is not the preferred way to do it. And although Bitnami has an excellent plethora of images running as non root users there will always be some cases where you want to run a container as root. Especially in your homelab.

For me this "issue" was particularly hard to google. Anyway here is how you do it.

Login.

oc login -u system:admin -n default

Create a new project.

oc new-project martintest

Add the security policy anyuid to the service account responsible for creating your deployment, by default this user is default. The dash z indicates that we want to manipulate a service account.

oc adm policy add-scc-to-user anyuid -z default

Now go ahead and deploy something in your project. I tested with nginx as it wants to bind to port 80. Something that you need root access to do.

Verify that the deployment was successful.