0

How can I update the PostgresSQL admin password each time the Docker Container restarts, even if the data directory is none empty?

According to the Postgres Documentation the variable will have no effect on restart:

Warning: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.

3
  • Does how to change Postgresql docker image password address your real need? You need to run an SQL ALTER USER statement, the same as any other PostgreSQL installation; while all of the examples there use docker exec, you should be able to do this with any SQL client tool. Commented Jun 9, 2024 at 15:26
  • Another approach could be to create a custom image with a custom startup script. The standard script checks for an empty database here before creating a database and running initialization scripts. Commented Jun 9, 2024 at 15:30
  • Thanks for the. tips @DavidMaze and HansKilian Commented Jun 9, 2024 at 17:40

0

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.