-
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
Unable to replace postgresql.conf #105
Comments
I guess the real problem is that the postgresql.conf file is in the same folder When installing postgres onto a system using apt-get, the configuration files If I compare the behaviour of this image to mysql I can see that mysql does not Given that this image behaves differently from the default postgres behaviour I |
For anyone finding this issue through a search, I ended up doing this:
Where set-config.sh is: #!/bin/sh
mv /postgresql.conf /var/lib/postgresql/data/postgresql.conf I do hope that this issue is fixed though. One fix that would be backwards compatible with existing images would be for the |
Hmm, perhaps it would make sense to add support for something like |
I think it's also worth noting that we haven't deviated from a standard postgres install in this regard -- it's the Postgres |
(This is my home account) If it could supplement the default file then that would be ideal. Looking quickly at the documentation I can see both individual file includes and directory includes: http://www.postgresql.org/docs/current/static/config-setting.html#CONFIG-INCLUDES
I'll have a little fiddle and see if I can come up with something. |
I'm writing this down in case I'm unable to solve the problem or you have ideas. In the postgresql source code the conf file is made by initdb as you state. This file is initialized from data read in at this point which comes from a file named here which has this content. This is where it gets a bit odd though. When I compare the postgresql.conf file that is created in the docker container with the sample one it is clearly different. I am testing this as follows:
It shows some 48 lines of difference. It turns out that the file is altered in the setup_config method. I guess they felt the example wasn't ideal for use in this situation. At this point I have not seen a way to alter the file through the initdb command options or anything promising in the code. I have only had a brief look. The next thing is to check the entrypoint script to see if I can alter it after initialization. Actually that looks extremely straightforward. So 9.5, 9.4 and 9.3 support There is no such option in the sample settings file for 9.2 but it is documented. There is no such option for 9.1 or 9.0. They support the plain include directive only. |
So it does read the $ diff -u <(curl https://raw.githubusercontent.com/postgres/postgres/REL9_4_STABLE/src/backend/utils/misc/postgresql.conf.sample) <(docker exec postgres cat /var/lib/postgresql/data/postgresql.conf)
@@ -56,16 +56,16 @@
# - Connection Settings -
-#listen_addresses = 'localhost' # what IP address(es) to listen on;
+listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
#port = 5432 # (change requires restart)
-#max_connections = 100 # (change requires restart)
+max_connections = 100 # (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction).
#superuser_reserved_connections = 3 # (change requires restart)
-#unix_socket_directories = '/tmp' # comma-separated list of directories
+#unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
@@ -112,7 +112,7 @@
# - Memory -
-#shared_buffers = 32MB # min 128kB
+shared_buffers = 128MB # min 128kB
# (change requires restart)
#huge_pages = try # on, off, or try
# (change requires restart)
@@ -127,7 +127,7 @@
#maintenance_work_mem = 64MB # min 1MB
#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
#max_stack_depth = 2MB # min 100kB
-#dynamic_shared_memory_type = posix # the default is the first option
+dynamic_shared_memory_type = posix # the default is the first option
# supported by the operating system:
# posix
# sysv
@@ -435,7 +435,7 @@
#log_temp_files = -1 # log temporary files equal or larger
# than the specified size in kilobytes;
# -1 disables, 0 logs all temp files
-#log_timezone = 'GMT'
+log_timezone = 'UTC'
#------------------------------------------------------------------------------
@@ -521,9 +521,9 @@
# - Locale and Formatting -
-#datestyle = 'iso, mdy'
+datestyle = 'iso, mdy'
#intervalstyle = 'postgres'
-#timezone = 'GMT'
+timezone = 'UTC'
#timezone_abbreviations = 'Default' # Select the set of available time zone
# abbreviations. Currently, there are
# Default
@@ -536,14 +536,14 @@
# encoding
# These settings are initialized by initdb, but they can be changed.
-#lc_messages = 'C' # locale for system error message
+lc_messages = 'en_US.utf8' # locale for system error message
# strings
-#lc_monetary = 'C' # locale for monetary formatting
-#lc_numeric = 'C' # locale for number formatting
-#lc_time = 'C' # locale for time formatting
+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
# default configuration for text search
-#default_text_search_config = 'pg_catalog.simple'
+default_text_search_config = 'pg_catalog.english'
# - Other Defaults - But that means a user can just mount their config to An alternative way would be to use a Dockerfile: FROM postgres:9.4
RUN sed -ri '/..../' "/usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample" \
&& echo 'extra config' >> "/usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample" |
Yeah I'm trying to make the change after the call to initdb at the moment. I have a patch I was just testing it. |
…tion This allows the default settings file to be supplemented with additional settings. It is possible to replace all settings in this way, so a complete configuration file can be used. This needs to be tested.
This allows the default settings file to be supplemented with additional settings. It is possible to replace all settings in this way, so a complete configuration file can be used. This needs to be tested.
👍 this would be really helpful. Any idea when it will be merged ? |
+1 for this... For example I would like to turn on logging (log_statement "all") for dev purposes by overriding default config.... FWIW i've been using https://github.com/sameersbn/docker-postgresql instead until this (hopefully) lands |
postgres added https://www.postgresql.org/docs/9.3/static/config-setting.html#CONFIG-INCLUDES If this was set to /etc/postgresql/conf.d then all you have to do would be to copy just your settings that are different into that dir which could be done in your dockerfile |
That is true. However that produces a greater variance between the supported versions as You could use |
FYI, you can inject docker run -d \
-v $CUSTOM_CONFIG:/etc/postgresql.conf \
-e POSTGRES_USER=postgres \
--name postgres \
postgres:9.6 postgres -c config_file=/etc/postgresql.conf Originally posted in StackOverflow question: http://stackoverflow.com/a/40598124/385548 |
Nice stuff @VojtechVitek! |
To extend the default configuration, I appended |
run this in daemon mode and it fails |
@rocketspacer, what is in your config file? Anything useful in |
@yosifkit I figured out the problem though. I set PGDATA to the same location where I put my custom postgres.conf. So inidb doesn't like it when it encounter a non-empty folder
Move PGDATA 1 level more deep should work
|
@bw-matthew I tried your solution :
config.sh: #!/bin/sh
rm -rf /var/lib/postgresql/data/postgresql.conf
mv /tmp/postgresql.conf /var/lib/postgresql/data/postgresql.conf then I run these instructions:
Then inside the container
The postgresql inside the container was [Postgresql.conf inside the docker container] (https://gist.github.com/slim-hmidi/2dc23850e474f8211ca32b775c6d34d3). However the configuration file in my local machine was Postgresql.conf in the local machine.
|
- solution found in docker-library/postgres#105
- solution found in docker-library/postgres#105
- solution found in docker-library/postgres#105
- solution found in docker-library/postgres#105
- solution found in docker-library/postgres#105
- solution found in docker-library/postgres#105
- solution was found in docker-library/postgres#105
- solution was found in docker-library/postgres#105
Hey,
or where can i directly overwrite the config file from where this is refrenced by mounting at that localtion? Thanks! |
Unfortunately, we do not have the bandwidth to provide in-depth integration/deployment/environment debugging or support here; these sorts of questions/requests would be more appropriately posted to a dedicated support forum, such as the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow. |
Using the dockerfile:
(the content of postgresql.conf doesn't matter - at the moment it is a duplicate of what would be there when the image starts)
I can build the image, but when I run it I get the error:
Why can't I just replace the config file in this way?
The text was updated successfully, but these errors were encountered: