How to switch user(su) in docker command

You need to use security context as like below

     runAsUser: 1000
     runAsGroup: 3000
     fsGroup: 2000


enter image description here


If you wanted to change the user in you container than, you can add extra layer of dockerfile, check below

Add dockerfile layer,

   FROM <your_image>
   RUN adduser newuser
   USER newuser

Now use above custom image in your kubernetes.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top