Search code examples
kubernetescontainers

Kubernetes - How to check if the Pod in K8S is running as root (or) non-root?


Is there a flag/field in kubectl describe pods which tells if the container is running as root or non-root, I have few containers, I need to check if they are running as root


Solution

  • You can run whoami command inside the pod to see the name of the users. You can also check if runAsUser field is specified in the securityContext of pod's manifest. Containers by default run as root users.

    For securityContext, check out examples in this link