# Mounted directory has the wrong ownership

**URL:** <https://discuss.kubernetes.io/t/mounted-directory-has-the-wrong-ownership/17034>\
**Category:** General Discussions\
**Created:** [August 11, 2021, 6:26am UTC](https://discuss.kubernetes.io/t/mounted-directory-has-the-wrong-ownership/17034 "2021-08-11T06:26:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zendevil](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/zendevil/32/8624_2.png) [@zendevil](https://discuss.kubernetes.io/u/zendevil)\
**Post date:** [August 11, 2021, 6:26am UTC](https://discuss.kubernetes.io/t/mounted-directory-has-the-wrong-ownership/17034/1 "2021-08-11T06:26:31Z")

</div>

I have the following kubernetes yaml file:

```auto
1 apiVersion: apps/v1
  1 kind: Deployment
  2 metadata:
  3 name: postgres-deployment
  4 spec:
  5 replicas: 1
  6 selector:
  7 matchLabels:
  8 component: postgres
  9 template:
 10 metadata:
 11 labels:
 12 component: postgres
 13 spec:
 14 securityContext:
 15 runAsUser: 999
 16 runAsGroup: 999
 17 fsGroup: 999
 18 volumes:
 19 - name: postgres-storage
 20 persistentVolumeClaim:
 21 claimName: postgres-persistent-volume-claim
 22 containers:
 23 - name: postgres
 24 image: prikshet/postgres
 25 ports:
 26 - containerPort: 5432
 27 volumeMounts:
 28 - name: postgres-storage
 29 mountPath: /var/lib/postgresql/data
 30 subPath: postgres
 31 imagePullPolicy: Always

```

But the pod is giving the following logs:

```auto
2021-08-11 06:06:15.749 GMT [8] LOG: skipping missing configuration file "/var/lib/postgresql/data/postgresql.auto.conf"
2021-08-11 06:06:15.750 UTC [8] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2021-08-11 06:06:15.750 UTC [8] HINT: The server must be started by the user that owns the data directory.

```

Whereas clearly I have the fsGroup, runAsUser and runAsGroup specified. What might be causing this error?

---

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [August 13, 2021, 2:55am UTC](https://discuss.kubernetes.io/t/mounted-directory-has-the-wrong-ownership/17034/2 "2021-08-13T02:55:53Z")

</div>

This was discussed in this ticket:

> [@Postgresql.conf not found when using volume mount](https://discuss.kubernetes.io/t/postgresql-conf-not-found-when-using-volume-mount/17009/3):
>
> Instead of doing a config map, I simply copy this file to another directory and run postgres with the configuration in the changed directory using -c config\_file: 1 FROM postgres:latest 1 ARG VERSION 2 3 COPY deployment/postgres\_init /docker-entrypoint-initdb.d 4 USER postgres 5 RUN initdb 6 CMD postgres -c hba\_file=/docker-entrypoint-initdb.d/pg\_hba.conf -c config\_file=/docker-entrypoint-initdb.d/postgresql.conf But now I see this error: prikshetsharma@Prikshets-MacBook-Pro humboi % kubectl logs -f postgres-deployment-64cbffd6d8-r5wtn 2021-08-10 05:42:14.072 GMT [7] LOG: ski…
