-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Pass important postgres settings to docker-entrypoint.sh via ENV vars #54
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
Conversation
If something like this is going to happen, I'd prefer to see it happen in a generic way based on prefix or something, rather than supporting specific settings. I could see having all |
Yes that is preferable. I'll work on that. |
Should be pretty straightforward with |
I didn't get it quite that elegant for now. But it works quite well. docker run -e POSTGRES_PASSWORD=mysecretpassword \
-e POSTGRES_CONF_SHARED_BUFFERS=25GB \
-e POSTGRES_CONF_WAL_LEVEL=minimal \
-e POSTGRES_CONF_EFFECTIVE_CACHE_SIZE=75GB \
-e POSTGRES_CONF_MAX_CONNECTIONS=200 -d postgres
But let's see. |
I don't know man, that's the first I'd seen of the |
|
||
conf_prefix="POSTGRES_CONF_" | ||
for env_name in $(env | cut -d= -f1 | grep "$conf_prefix.*"); do | ||
value=$env_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually work? I'd think you would need to do eval value="\$${env_name}"
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. Just saw the ${!value}
below.
Thanks for the comments, I fixed the issues and it still works 😁 Expanding the vars with |
Isn't the generated |
@tianon, it is mostly the same, but I don't know where it gets most of the changes: root@14814ca1bbe4:/var/lib/postgresql/data# diff postgresql.conf /usr/share/postgresql/9.4/postgresql.conf.sample
59c59
< listen_addresses = '*' # what IP address(es) to listen on;
---
> #listen_addresses = 'localhost' # what IP address(es) to listen on;
64c64
< max_connections = 100 # (change requires restart)
---
> #max_connections = 100 # (change requires restart)
68c68
< #unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
---
> #unix_socket_directories = '/tmp' # comma-separated list of directories
115c115
< shared_buffers = 128MB # min 128kB
---
> #shared_buffers = 32MB # min 128kB
130c130
< dynamic_shared_memory_type = posix # the default is the first option
---
> #dynamic_shared_memory_type = posix # the default is the first option
438c438
< log_timezone = 'UTC'
---
> #log_timezone = 'GMT'
523c523
< datestyle = 'iso, mdy'
---
> #datestyle = 'iso, mdy'
525c525
< timezone = 'UTC'
---
> #timezone = 'GMT'
538c538
< lc_messages = 'en_US.utf8' # locale for system error message
---
> #lc_messages = 'C' # locale for system error message
540,542c540,542
< lc_monetary = 'en_US.utf8' # locale for monetary formatting
< lc_numeric = 'en_US.utf8' # locale for number formatting
< lc_time = 'en_US.utf8' # locale for time formatting
---
> #lc_monetary = 'C' # locale for monetary formatting
> #lc_numeric = 'C' # locale for number formatting
> #lc_time = 'C' # locale for time formatting
545c545
< default_text_search_config = 'pg_catalog.english'
---
> #default_text_search_config = 'pg_catalog.simple' |
You think we should write the settings to |
Should I continue to modify the Dockerfiles of all versions or should we just support it for the newest one? |
What I meant was that if we can figure out which file these settings come from, we can recommend that users modify that file directly instead. I ran a test appending some content to the end of What this means for my opinion on this PR is that I'd prefer that we instead document to users where Something like |
Yes that's a good option. But I think it is significant more work to create an own Docker Image and configure an automated build with repository links than just setting an environment variable for a config value that is nearly always too conservative. Settings like |
Really cool your patch, Lukas, I hadn't seen before and copied this to my /docker-entrypoint-initdb.d/ :
|
No thats correct and it is problematic - I mean we also cannot modify the postgres config once it has been mounted in But I think we need a solution that very essential things like the |
With the incoming #127 you can more easily pass parameters to postgres: $ docker run -d postgres -c shared_buffers=256MB ... Or override the default config file with your own, so that postgres will use it to generate the real one: $ docker run -d -v /my/pg.conf:/usr/share/postgresql/postgresql.conf.sample postgres |
|
Nope, I mean passing args to the postgres daemon itself: |
Reading through this closed ticket, I'm still not sure how to pass |
Thanks for your work so far guys!
The postgres defaults are quite modest (especially memory). Most settings can nowaydays be set via the
ALTER SYSTEM
query and a reload but some settings require a restart and therefore should be set before postgres starts.This is just a proposal how it could be done. I would be happy to see what you think about it and which settings to include and whether it is even in the scope of this Docker image.
I think it would make quick configuration of postgres containers much easier because you don't have to create your own Docker image just for tweaking some very basic settings like
shared_buffers
.It also allows schedulers for example to set the
shared_buffers
options based on metadata.I simply modified the
docker-entrypoint.sh
of the latest Docker image for now, if you think it is a good idea in general I will modify the others as well.