PostgreSQL 11 – Fix Parameter Not Working in Docker

dockerpostgresql

I'm running a Postgres inside a docker. I want to change the default config of Postgres so I'm running :

docker container run -d postgres -c max_connections=200 -c shared_buffers = 1GB -c effective_cache_size=3GB -c maintenance_work_mem=256MB -c checkpoint_completion_target=0.7 -c wal_buffers=16MB 

But when I'm connecting to Postgres running:

 docker exec -it container_name psql

And then the result of :

SHOW max_connections;

is

 max_connections
-----------------
 100
(1 row)

And it's not just max_connections. None of the parameters are changed. And I don't know what is the problem with what I'm doing?

Update: I already have a running docker container and I want it to apply these parameters to it without needing to restart it.

Best Answer

You cannot put spaces around the equals sign when using the "-c" option. So you need something like postgres -c max_connections=200

When I try it with the spaces, it refused to start at all. So I don't know what you are connecting to in order to SHOW max_connections;. Maybe you already had a server running before you tried to start with the invalid syntax?