postgres icon indicating copy to clipboard operation
postgres copied to clipboard

Add an option to skip DB init check

Open xtexx opened this issue 10 months ago • 2 comments

https://github.com/docker-library/postgres/blob/master/16/alpine3.19/docker-entrypoint.sh#L234

Currently, checking if the DB is initialized is by checking if $PGDATA/PG_VERSION if exist. However, PGDATA may not be the real data directory. The real data directory can be overwritten by $PGDATA/postgresql.conf with data_directory = ''.

xtexx avatar Mar 31 '24 07:03 xtexx

IMO that sounds like an argument for asking PostgreSQL to give us the value of data_directory, not an argument for skipping the check :sweat_smile:

https://www.postgresql.org/docs/8.0/runtime-config.html#:~:text=If%20you%20wish%20to,of%20the%20configuration%20files is a really interesting/useful reference :eyes:

tianon avatar Apr 01 '24 17:04 tianon

How about getting data_directory, when postgresql.conf exists, through:

  -C NAME            print value of run-time parameter, then exit
/ # echo $PGDATA
/var/lib/postgresql
/ # cat /var/lib/postgresql/postgresql.conf | grep data_directory
data_directory = '/var/lib/postgresql/data'
/ # postgres -C data_directory
/var/lib/postgresql/data

xtexx avatar Apr 03 '24 09:04 xtexx