Skip to content

Postgres container fails to start due to permissions issue #1213

@achint740

Description

@achint740

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 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions