Skip to content

Add hook to execute scripts before startup, and allow them to add arguments to the startup #591

New issue

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

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

Already on GitHub? # to your account

Closed
thijslemmens opened this issue Jun 21, 2019 · 2 comments

Comments

@thijslemmens
Copy link

I would like to be able to hook in just before PostgreSQL starts and add my own script there.
I would use it to add a script that reads environment variables that start with PGCONF_ and add them to the startup parameters.
example:
docker run -e PGCONF_log_checkpoints=on postgres

This would start postgres with argument log_checkpoints=on

I already use this for a while, but I needed to do some sed in the init script to make it possible. I would be happy to contribute a PR, but I want to make sure this is something that can be accepted.
I replaced the last line with this script:
https://github.com/xenit-eu/docker-postgres/blob/master/src/main/docker/before-startup.sh
Our images are published on docker hub:
xeniteu/postgres

@yosifkit
Copy link
Member

We are unlikely to add new hooks but we are still looking to make customization more flexible in #496. This seems partly like a duplicate of #317 (if the goal is changing flags only during first initialization).

As for changing config or arguments to postgres, you could just pass them as arguments to the container (https://github.com/docker-library/docs/tree/c6e632675a629be6559b1539d0ab9ace5a4f59d8/postgres#database-configuration) without having to pass them as a single env var that is then passed as a flag.

$ docker run -d -e POSTGRES_PASSWORD=12345 postgres -c log_checkpoints=on

@thijslemmens
Copy link
Author

Thanks @yosifkit

I know I can add things on the command line with the default images, but with the environment variables it looks a bit cleaner in compose files. It is also nicer to add layers with layered compose files.
We also have a script that writes pg_hba before startup.

Anyway, #496 should give me all the flexibility I need without having to hack the entrypoint script.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants