Reputation: 1711
Docker allows execution of commands as other user with docker exec -u
, when USER something
in used in Dockerfile.
It is helpful to enter into superuser mode to debug issues, when you are running you CMD
as system user in Dockerfile.
How to execute commands on Kubernetes as other user?
My kubectl version output is
Client Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.6", GitCommit:"388061f00f0d9e4d641f9ed4971c775e1654579d", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.6", GitCommit:"388061f00f0d9e4d641f9ed4971c775e1654579d", GitTreeState:"clean"}
Upvotes: 6
Views: 12602
Reputation: 558
This is not currently supported, but there is an open feature request for it: https://github.com/kubernetes/kubernetes/issues/30656
Upvotes: 1
Reputation: 2199
You can check the spec schema to see what you can add in a pod or replication controller or whatever: https://cloud.google.com/container-engine/docs/spec-schema
You have runAsUser for what you want:
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
securityContext:
runAsUser: 41
Upvotes: 7