Skip to content

Simple way to import configuration #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ringerc opened this issue May 17, 2019 · 6 comments
Closed

Simple way to import configuration #581

ringerc opened this issue May 17, 2019 · 6 comments
Labels
Request Request for image modification or feature

Comments

@ringerc
Copy link

ringerc commented May 17, 2019

This container is rather handy but I've found it more difficult than I expected to apply a non-default configuration. Specifically I needed to install SSL certificates and keys, apply some postgresql.conf entries and modify pg_hba.conf.

To do so I had to create a setup script in /docker-entrypoint-initdb.d/ to overwrite pg_hba.conf, append to postgresql.conf and copy the SSL certs in from a bind mounted volume. Originally I actually went further and made a derived container that copied these things in before I realised I could just bind mount.

I suggest:

  • document that bind-mounting /docker-entrypoint-initdb.d/ is a good way to run scripts and load configuration;
  • Special case a /docker-entrypoint-initdb.d/copy-files.d/ directory. When present, copy everything in copy-files.d to the new datadir (recursively, preserving mode and changing ownership to container user). So you can add an include_dir etc.
  • Special case a /docker-entrypoint-initdb.d/append-files.d/ directory. When present, append everything in append-files.d to the new datadir with the same filename, creating it if it doesn't exist.
  • Auto-append include_dir 'postgresql.conf.d' to the generated postgresql.conf. Document that any config file snippet placed in /docker-entrypoint-initdb.d/copy-files.d/postgresql.conf.d/ will be copied to the datadir and loaded as part of PostgreSQL's configuration. Or alternately just special case postgresql.conf.d in the docker-entrypoint-initdb.d and auto-enable include_dir if it's present.
  • Make it more obvious in the docs that scripts in /docker-entrypoint-initdb.d/ run as the postgres user.
@wglambert wglambert added the Request Request for image modification or feature label May 17, 2019
@vkukk
Copy link

vkukk commented Oct 23, 2019

Anything local should be avoided, in cluster it's especially important. Instead of mounting something under /docker-entrypoint-initdb.d/ use docker configs and copy config into that directory.

configs:
  your-config:
    file: ./some_config_script.sh
services:
  postgresql:
    configs:
      - source: your-config
        target: /docker-entrypoint-initdb.d/some_script_name.sh
        uid: 'uid_of_postgresuser'
        mode: 0700

@oshmyrko
Copy link

I like the idea to have simple way to import configuration, especially postgresql.conf.d in the docker-entrypoint-initdb.d and auto-enable include_dir if it's present.

And I still cannot understand why include_dir still does not have default value in default postgresql.conf. It would be much easier to import own configs without modifying original one (in order to logically separate them), if there was default value in include_dir.

@marko-asplund
Copy link

Anything local should be avoided, in cluster it's especially important. Instead of mounting something under /docker-entrypoint-initdb.d/ use docker configs and copy config into that directory.
...

@vkukk It may not always be possible to use docker-compose.
In those cases customizing server config can be tricky.

@yosifkit
Copy link
Member

yosifkit commented Jun 9, 2021

#835 (comment)

@tianon
Copy link
Member

tianon commented Jun 8, 2022

Unfortunately, we're not going to add additional behavior to the image as-is to enable this use case. However, as noted/demonstrated in #835 (comment), it isn't too hard to accomplish with what we do provide. 👍

@tianon tianon closed this as completed Jun 8, 2022
@ShPakvel
Copy link

ShPakvel commented May 19, 2023

Unfortunately, we're not going to add additional behavior to the image as-is to enable this use case. However, as noted/demonstrated in #835 (comment), it isn't too hard to accomplish with what we do provide. +1

@tianon It would be nice to provide at least reason(s), why such simple and seems not harmful change to default include_dir = 'conf.d' cannot be provided?
Once again, pros:

=================
Side remark. On image docs there is wrong information.

From the PostgreSQL docs we see that any option available in a .conf file can be set via -c.

It is actually doesn't work for any "include" type configuration. I suggest to add that information to save time on investigation for other people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

8 participants