I\'m using the official Postgres Docker image trying to customize its configuration. For this purpose, I use the command sed
to change max_connections
You can put your custom postgresql.conf
in a temporary file inside the container, and overwrite the default configuration at runtime.
To do that :
postgresql.conf
inside your containerupdateConfig.sh
file in /docker-entrypoint-initdb.d/
Dockerfile
FROM postgres:9.6
COPY postgresql.conf /tmp/postgresql.conf
COPY updateConfig.sh /docker-entrypoint-initdb.d/_updateConfig.sh
updateConfig.sh
#!/usr/bin/env bash
cat /tmp/postgresql.conf > /var/lib/postgresql/data/postgresql.conf
At runtime, the container will execute the script inside /docker-entrypoint-initdb.d/
and overwrite the default configuration with yout custom one.