Only in an ideal world are all standards observed...

Docker has different standards inside.

$ ls -l /home/neo/
drwxr-xr-x    2 pgsql      pgsql           8192 May 27 10:37 data
drwxr-sr-x    2 pgsql      pgsql           4096 May 24 09:35 data2

/home/pgsql/data - mounted volume.

Therefore, the permissions have changed to drwxr-xr-x

$ mkdir /home/pgsql/data/pgtest
$ ls -l /home/pgsql/data
drwxr-xr-x    2 pgsql      pgsql              0 May 27 11:08 pgtest

$ chmod 700 /home/pgsql/data/pgtest
$ ls -l /home/pgsql/data
drwxr-xr-x    2 pgsql      pgsql              0 May 27 11:08 pgtest

Oops...

If it's a regular "data2" folder and there is no "read_only: true" flag for the container:
$ mkdir /home/pgsql/data2/pgtest
$ chmod 700 /home/pgsql/data2/pgtest
$ ls -l /home/pgsql/data2
drwx------    2 pgsql      pgsql           4096 May 27 11:19 pgtest

Roffild writes:
postgres and initdb not working inside docker.
chmod 755 always for a mounted volume inside docker.

This patch will never be accepted.  You don't need it if you take the
standard advice[1] that the Postgres data directory should not itself
be a mount point.  Instead, make a subdirectory in the mounted volume,
and that can have the ownership and permissions that the server expects.

                        regards, tom lane

[1] https://www.postgresql.org/message-id/12168.1312921709%40sss.pgh.pa.us


Reply via email to