PostgreSQL Docker: Set a config AND create a user

:warning: IMPORTANT, please fill the questions

We assume you are using Bitnami to deploy your application.

  • Which version of the application are you using?:
    I’m using docker-compose on the 11-debian-9 image

  • Please choose how you got the application: Installer (Windows, Linux, macOS), cloud image (AWS, GCE, Azure, …) or VM (VMDK, VBOX):
    Docker download

  • Have you installed any plugin or modified any configuration file?:
    Yes, I’m trying to feed it a configuration file

  • Describe here your question/suggestion/issue (expected and actual results):
    I want to deploy a simple master-slave pair using the replication options, as well as give it my own custom postgresql.conf file. If I try and give it a config file, it will not create the replication user, the database, or any user specified under POSTGRESQL_USERNAME. If I remove the custom file from the equation, it will create all the users/db as expected. Is there a way to do both via the arguments without having to resort to writing my own sql setup files?

  • Steps to reproduce the issue (if relevant):

  1. Write a docker-compose YAML file, like this:
version: '3'
    image: bitnami/postgresql:11-debian-9
    restart: always
      - ''
        - POSTGRESQL_PASSWORD=testpasswd
        - POSTGRESQL_USERNAME=testuser
        - POSTGRESQL_DATABASE=testdb
     - /data/config:/opt/bitnami/postgresql/conf # contains a custom postgresql.conf

(slave will have the same repuser/password in its yaml)
2. Run it with docker-compose up -d
3. Go into the container via bash
4. Use psql in /opt/bitnami/postgresql/bin to get into the db with pgsql -U postgres
5. Run \l to list databases, see that testdb was not created and only the default postgres ones are present
6. Run \du and see that neither testuser or repuser was created - the only user is postgres
7. The slave fails to connect with repuser since it does not exist

Verify that the config file is the issue:
8. Remove the line - /data/config:/opt/bitnami/postgresql/conf from the master yaml file above
9. Delete the previous container and re-run docker-compose up -d
10. Repeat steps 3-4
11. Run ‘\l’ and ‘\du’ and notice the db and the users are now both created as expected

I would love to edit this to fix the formatting, but apparently I can’t, there’s no button to do so.

Hi, @ewalkup

Would you mind posting this message in the issues section of the GitHub container repository? We track the container issues there.

Was my answer helpful? Click on :heart:

Done, posted here:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.