run container as root user

1/23/2018

Is there any way I can run container in k8s as root user or other user. Like in docker

docker run --user <user> <image>

Is there any yaml configuration for running with

-- Itay Gil
containers
docker
kubernetes

1 Answer

1/23/2018

As described in the kubernetes docs, you can set the security context for the container and set the runAsUser property as such:

 containers:
  - name: ...
    image: ...
    securityContext:
      runAsUser: 0

This will make the container execute internally as the root user.

-- yamenk
Source: StackOverflow