Open
Description
https://www.postgresql.org/docs/15/runtime-config-file-locations.html
If you wish to keep the configuration files elsewhere than the data directory, the
postgres -D
command-line option orPGDATA
environment variable must point to the directory containing the configuration files, and thedata_directory
parameter must be set inpostgresql.conf
(or on the command line) to show where the data directory is actually located. Notice thatdata_directory
overrides-D
andPGDATA
for the location of the data directory, but not for the location of the configuration files.
$ sudo grep data_directory /example/postgresql.conf
data_directory = '/var/lib/postgresql/data' # use data in another directory
$ sudo docker run -e PGDATA=/etc/postgresql -e POSTGRES_PASSWORD=foo -v /example/postgresql.conf:/etc/postgresql/postgresql.conf -v /example/postgresql-data:/var/lib/postgresql/data postgres:15.2
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
initdb: error: directory "/etc/postgresql" exists but is not empty
initdb: hint: If you want to create a new database system, either remove or empty the directory "/etc/postgresql" or run initdb with an argument other than "/etc/postgresql".
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
Am I missing something? I'm trying to have postgres
to look at my config file, see data_directory
, and initialize a new DB in data_directory
if it is empty, otherwise use it as-is.
Metadata
Metadata
Assignees
Labels
No labels