docker-library / postgres

Docker Official Image packaging for Postgres
http://www.postgresql.org
MIT License
2.16k stars 1.13k forks source link

Postgres 11 set wal_level at startup #1074

Closed edalongeville closed 1 year ago

edalongeville commented 1 year ago

Hello,

I'm trying to start a postgres:11 container with the wal_level set to logical. Looking into this documentation page, it looks like this option is not available.

The only option I found in the documentation is to use ALTER SYSTEM and restart the container.

Is there a way to start a postgres 11 container directly with the wal_level set to logical, without having to restart the container ?

tianon commented 1 year ago

You should be able to use -c:

$ docker run -it --rm --env POSTGRES_PASSWORD=foo postgres:11 -c wal_level=logical
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Etc/UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2023-05-04 18:33:56.832 UTC [48] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-05-04 18:33:56.844 UTC [49] LOG:  database system was shut down at 2023-05-04 18:33:56 UTC
2023-05-04 18:33:56.851 UTC [48] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down....2023-05-04 18:33:56.988 UTC [48] LOG:  received fast shutdown request
2023-05-04 18:33:56.993 UTC [48] LOG:  aborting any active transactions
2023-05-04 18:33:56.997 UTC [48] LOG:  background worker "logical replication launcher" (PID 55) exited with exit code 1
2023-05-04 18:33:56.997 UTC [50] LOG:  shutting down
2023-05-04 18:33:57.012 UTC [48] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2023-05-04 18:33:57.105 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-05-04 18:33:57.105 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-05-04 18:33:57.110 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-05-04 18:33:57.121 UTC [67] LOG:  database system was shut down at 2023-05-04 18:33:57 UTC
2023-05-04 18:33:57.126 UTC [1] LOG:  database system is ready to accept connections
tianon commented 1 year ago

For further help, I would suggest trying a dedicated support forum, such as the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow.