Bootstrap FreeKB - OpenShift - Resolve "You need to be root to perform this command"
OpenShift - Resolve "You need to be root to perform this command"

Updated:   |  OpenShift articles

Let's say the following is being returned when attempting to do something in a pod, such as attempting to install a package.

[Errno 13] Permission denied: '/var/lib/rpm/.dbenv.lock'
You need to be root to perform this command.
command terminated with exit code 1

 

As the error suggests, this means you are not running the pod as root. The oc exec and whoami commands can be used to determine who you are running the pod as.

~]$ oc exec pod/my-app-pzrfj -- whoami
john.doe

 

This can be resolved up updating the deployment to runAsUser 0 (root). The oc get deployments command can be used to list the deployments in a project / namespace.

~]# oc get deployments
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
my-app    1/1     1            1           8d

 

The oc edit deployment command can be used to edit the deployments YAML. In this example, the container in the deployment is updated to be runAsUser 0 (root).

spec:
  template:
    spec:
      containers:
      - image: api.openshift.example.com/myapp
      securityContext:
        runAsUser: 0

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 493df4 in the box below so that we can be sure you are a human.