Reputation: 3118
After reading about kubernetes pod security context in the k8s documentation (https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) - I have a question that I could not find an answer to.
The security context allows adding runAsUser setting with a user ID. Can this be used to run a container image that has NOT been modified to run as a non-root user. Meaning if the runAsUser is set to say 1000 and the container image that runs in this pod, does not use a USER directive / or basically is built to run as root, will the runAsUser setting override the container image? Will the container run with user 1000 or will it continue to run as root?
Working on to setup Kubernetes and try this scenario in a cluster but would like to understand the concept and what the expected behavior is.
Upvotes: 4
Views: 3486
Reputation: 6271
Yes this will run the container with the provided user id (ignoring the user in the container image).
Upvotes: 2