-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow args to be passed to Postgres during init #317
Conversation
..sometimes it's desirable to pass additional arguments to Postgres when it's started for the init scripts This change allows those to be given by setting a POSTGRES_INIT_ARGS environment variable
I'm open to changing the name of this environment variable, it's chosen to be similar to the existing |
Interesting! Can you elaborate a bit on what the use case of this is? What sorts of things would you specify with this feature that you'd want enabled on the initial run of the database but not on subsequent runs? |
Hi @tianon - sure. The first time I wanted this feature was when our init script started giving back errors about Recently I've realised that for our integration tests I can set fsync off and our init scripts run about twice as fast, which reduces the time taken for test runs. Obviously it's not recommended to have this setting off during normal operation So this would be useful to us. For the timebeing we've hacked it by wrapping
Obviously this isn't particularly clean and is pretty prone to breaking should the structure of docker-entrypoint change |
Interesting, so there are parameters that are useful to tweak while you're loading your initial dataset, but then you don't want those same parameter changes at runtime? Won't you potentially run into the same errors/warnings at runtime if you then reset those parameters after the initial data load? |
It depends on the setting During normal operation I wouldn't expect to be getting enough load to hit the checkpoint_segments warning, and if I did it would probably need to be more carefully tuned. The initial data load just wants to go as fast as it can. Turning off fsync massively helps with the speed of the initial data load but you definitely don't want to be running that during normal operation. For the initial load it's acceptable to turn off because if your db crashes during your load it's very hard to write a script that can be restarted halfway through anyway (at least, it's easier and safer to just start a new container especially if it's fast) |
I'd like this change as well, in ovirt we tweak the postgres configuration for max_connection and autovacuum etc. I would add to that enabling the include_dir by default in postrgresql.conf so one can pass a directory with custom configuration |
I'm looking for the same functionality as well. Our use-case is running two postgres containers in the same pod on Kubernetes. To do this, we currently
This works, except that
|
For our use-case, I've switched to https://github.com/sameersbn/docker-postgresql#creating-databases, which supports:
|
@driverpt right, that's completely possible today; see @yosifkit's recent documentation PR: docker-library/docs#1095 |
@tianon , that has a problem. docker-entrypoint skips all the defaults if postgres is contained in the COMMAND part |
@driverpt, I don't follow. If the command contains $ docker run -d --name some-postgres postgres:10.1 -c 'shared_buffers=256MB' -c 'max_connections=20000'
4f5db51d1fe68d9b51c0f10b4a420ec431224b815c2649d23056f86c26a50e7d
$ docker run -it --rm --link some-postgres postgres psql -h some-postgres -U postgres
psql (10.1)
Type "help" for help.
postgres=# show shared_buffers;
shared_buffers
----------------
256MB
(1 row)
postgres=# show max_connections;
max_connections
-----------------
20000
(1 row)
postgres=# Regardless, this issue is about arguments to the temporary postgres server that is run only during initialization. |
I submitted #499 due to the same needs as @spmason (sorry missed this in my search of issues). On initialization we're loading a lot of data and the modification of |
I think #496 is really our best bet here -- functionalizing the entrypoint would allow for trivially implementing edge-case custom behavior like this without explicit official support via a new environment variable. |
Breaking the entrypoint into reusable functions is totally worth doing but in this case I want entrypoint to do everything it does. I only need to pass options into |
I agree with @gsf . There are two modes I would like to have
Right now official image allows me to tweak 2.), where this PR adds easy way how to tweak 1.) |
This was resolved in #496 -- it allows for two things relevant to this proposal:
|
..sometimes it's desirable to pass additional arguments to Postgres when it's started for the init scripts
This change allows those to be given by setting a POSTGRES_INIT_ARGS environment variable