I know this issue FATAL: data directory "/var/lib/postgresql/data" has wrong ownership has been discussed a lot of times. I've gone through a lot of such issues and tried to fix it at my end, but none has been helpful. I will list down more details below.
I am using this docker image : postgres:12.5-alpine. I have a NFS mount like /<nfs_mount_name>/postgres/data.
Earlier my deployment was using docker-compose through the root user but recently I am trying to shift to using podman.
The NFS mount has permissions drwxr-xr-x with the owner being, say user 'A' and group 'B'. Now, I try to run a container using podman run --user <uid_of_user_A>:<gid_of_user_B> -v <my_nfs_mount>:/var/lib/postgresql/data --env-file .env.pg postgres:12.5-alpine
The .env.pg contains POSTGRES_USER and POSTGRES_PASSWORD.
The detailed error look like :
chmod: /var/lib/postgresql/data: Operation not permitted
chmod: /var/run/postgresql: Operation not permitted
PostgreSQL Database directory appears to contain a database; Skipping initialization
FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
HINT: The server must be started by the user that owns the data directory.
Let me know for any additonal information required. Any help would be much appreciated!
Thanks
@yosifkit if you might have more context and can help here? Sorry for tagging, but I noticed your solutions in a couple of similar cases to be useful.
Thanks
Hello everyone,
I know this issue
FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
has been discussed a lot of times. I've gone through a lot of such issues and tried to fix it at my end, but none has been helpful. I will list down more details below.I am using this docker image :
postgres:12.5-alpine
. I have a NFS mount like/<nfs_mount_name>/postgres/data
. Earlier my deployment was using docker-compose through the root user but recently I am trying to shift to using podman.The NFS mount has permissions
drwxr-xr-x
with the owner being, say user 'A' and group 'B'. Now, I try to run a container usingpodman run --user <uid_of_user_A>:<gid_of_user_B> -v <my_nfs_mount>:/var/lib/postgresql/data --env-file .env.pg postgres:12.5-alpine
The.env.pg
containsPOSTGRES_USER
andPOSTGRES_PASSWORD
.The detailed error look like :
Let me know for any additonal information required. Any help would be much appreciated! Thanks