Docker image - set umask for pod started as different user

313 views Asked by At

I am trying to modify the umask value by adding it to my entrypoint script:

#!/bin/bash
umask 022
/sbin/rsyslogd

ENTRYPOINT ["/bin/sh", "-c" , "/var/run/scripts/entrypoint.sh"]

However, this doesn't seem to get modified. The pod is started up with a different user - is this affecting it? If so, what are the options to modify the umask this way?

1

There are 1 answers

0
peppie On

Could you clarify what is not working here?

I understand that your umask configuration is correct but the user used in the pod is not. I assume you are using Kubernetes if you refer to pods, in this case you should use the security context to specify the user id you want to execute your pod as. Example to launch your pod with UID set as 1000 :

apiVersion: v1
kind: Pod
metadata:
  name: security-context-demo
spec:
  securityContext:
    runAsUser: 1000

Documentation here : https://kubernetes.io/docs/tasks/configure-pod-container/security-context/