<p>I try to mount a folder that is non-root user(xxxuser) at kubernetes and I use hostPath for mounting. But whenever container is started, it is mounted with user (1001) not xxxuser. It is always started with user (1001). How can I mount this folder with xxxuser ?     </p>

<p>There is many types of volumes but I use hostPath. Before started; I change folder user and group with chown and chgrp commands. And then; mounted this folder as volume. Container started and I checked user of folder but it always user (1001). Such as;</p>

<p>drwxr-x---. 2 1001 1001   70 May  3 14:15 configutil/</p>

<pre><code>volumeMounts:
        - name: configs
          mountPath: /opt/KOBIL/SSMS/home/configutil
      volumes:
      - name: configs
        hostPath:
          path: /home/ssmsuser/configutil
          type: Directory
</code></pre>

<p>drwxr-x---. 2 xxxuser xxxuser 70 May  3 14:15 configutil/</p>

O.Kaplan
<p>I try what you have recomend but my problem is still continue. I add below line to my yaml file:</p>

<pre><code>spec:
      securityContext:
        runAsUser: 999
        runAsGroup: 999
        fsGroup: 999
</code></pre>

<p>I use 999 because I use 999 inside my Dockerfile. Such as;</p>

<pre><code>RUN groupadd -g 999 ssmsuser &amp;&amp; \
useradd -r -u 999 -g ssmsuser ssmsuser
USER ssmsuser
</code></pre>
