1

I'm trying to override a single item in the Postgres configuration of the official Docker Postgres image. Namely, I want to override the log_statement property and set it to all.

Tried it with:

docker run -d -e POSTGRES_PASSWORD=postgres postgres -c 'log_statement=all' 

After enter the docker container and execute:

cat /var/lib/postgresql/data/postgresql.conf | grep log_statement

is still get the default value which is none.

but without success.

There are a few answers/questions regarding Postgres Docker configuration but they suggest replacing the complete postgresql.conf file.

1
  • It is a temporary override, in effect, and not actually modifying the configuration file. Commented Jun 14 at 11:59

3 Answers 3

2

From the docs:

Command-line options override any conflicting settings in postgresql.conf. Note that this means you won't be able to change the value on-the-fly by editing postgresql.conf, so while the command-line method might be convenient, it can cost you flexibility later.

As far as I understand that doesn't change the postgresql.conf but it actually runs the postgres command with the desired options. That's probably why you don't see the value set to all in the configuration file.

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

0

My solution is to mount Postgres config file somewhere on the server and edit it.

Comments

0

I test your question in my pc. In the postgresql.conf log_statement="none" is commented. Go manually and discomment it and it solve your problems.

docker exec -it postgres bash

Into the container:

  • apt update
  • apt install vim
  • vim /var/lib/postgresql/data/postgresql.conf
  • search what do you are looking for and change it manually.
  • Stop/start the container.

That is my solution.

2 Comments

This requires manual intervention every time the container is restarted.
No, with one time is enough, ensure you test the solutions before comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.