docker-library / docker-library/postgres
Separating config using PGDATA does not seem to behave as described in the docs
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 2.5k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
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 -Dcommand-line option orPGDATAenvironment variable must point to the directory containing the configuration files, and thedata_directoryparameter must be set inpostgresql.conf(or on the command line) to show where the data directory is actually located. Notice thatdata_directoryoverrides-DandPGDATAfor 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the exact postgres:15.2 Docker command with PGDATA, the mounted postgresql.conf, and data_directory described in the issue. Compare the observed initialization behavior with PostgreSQL's runtime configuration file locations documentation; done means establishing whether the image behavior or the documentation conflicts with the expected setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, postgresql
- Domain
- databases, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100