Docker Community Forums

Share and learn in the Docker community.

Postgresql container with multiple users and dbs


I am writing a compose file which has two apps (app1,app2) containers and one postgresql container. The requirement is to, create multiple postgresql db’s / users so that each app container use it’s own db and role. I wrote the following, but it only creates one set (app1db & app1user). Please help on how to achieve this.

indent preformatted text by 4 spaces
  - 'POSTGRES_USER=app1user'
  - 'POSTGRES_USER=app2user'
  - 'POSTGRES_PASSWORD=password'
  - 'POSTGRES_DB=app1db'
  - 'POSTGRES_DB=app2db'

Thank you in advance

Check out this repo: Docker Hub