Re: postgres and initdb not working inside docker

From: Roffild <roffild(at)hotmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgres and initdb not working inside docker
Date: 2022-05-27 08:50:04
Message-ID: DB9P193MB11772BDB553C9BB049055800B3D89@DB9P193MB1177.EURP193.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2022-05-27 09:07:46 RE: Support logical replication of DDLs
Previous Message Peter Smith 2022-05-27 08:38:25 Re: Handle infinite recursion in logical replication setup