Skip to content

Simple way to import configuration #581

Closed
@ringerc

Description

@ringerc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RequestRequest for image modification or feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions