Having multiple DBs served from one instance has pros and cons. The pros is that it’s all centralized and is easier to run. The problems are that the performance when accessing can be very up-n-down. Especially if your hosting databases for, lets say Davinci Resolve. I’d recommend giving programs like Resolve its own Postgres instance.
POSTGRES_MULTIPLE_DATABASES
This variable holds all the names of your databases. Note, this is ONLY used if your database folder directory is empty. It will NOT overwrite existing DBs.
Postgresql_scripts
This directory will contain the “init-user-db.sh” script we will create below.
The Script
In the directory postgresql_scripts
your gonna create a shell script named “init-user-db.sh”. Paste this code inside it:
This script will check the “POSTGRES_MULTIPLE_DATABASES” variable and create databases using the names supplied. If the dbs already exists, it will do nothing.
Refrences
- PostgreSQL at Docker.io
https://hub.docker.com/_/postgres