Use multiple databases with the official PostgreSQL Docker Image.
postgres-multiple-databases is available on Docker Hub. You can use it with the same tags as the official PostgreSQL Docker image.
docker pull danielptv/postgres-multiple-databases:latest
postgres-multiple-databases is available on the GitHub Container Registry. You can use it with the same tags as the official PostgreSQL Docker image.
docker pull ghcr.io/danielptv/postgres-multiple-databases:latest
Alternatively, you can clone the repository and build a custom image using the provided Dockerfile
.
git clone https://github.com/danielptv/postgres-multiple-databases.git
cd postgres-multiple-databases
docker build --tag <CUSTOM_TAG> --build-args="POSTGRES_TAG=<POSTGRES_TAG>"
Replace <CUSTOM_TAG>
with your desired image tag and <POSTGRES_TAG>
with the tag you want to use for the PostgreSQL base image.
If omitted, <POSTGRES_TAG>
will default to latest
.
This repository extends the official PostgreSQL Docker Image by adding an additional environment variable POSTGRES_MULTIPLE_DATABASES
.
Additional databases can be passed as a comma-separated list in different formats:
postgres:
image: eu.gcr.io/your-project/postgres-multi-db
environment:
- POSTGRES_MULTIPLE_DATABASES=database1:username1:password1,database2:username2,password2
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=database
postgres:
image: eu.gcr.io/your-project/postgres-multi-db
environment:
- POSTGRES_MULTIPLE_DATABASES=database1:username1,database2:username2
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=database
Passwords will default to the value of POSTGRES_PASSWORD
.
postgres:
image: eu.gcr.io/your-project/postgres-multi-db
environment:
- POSTGRES_MULTIPLE_DATABASES=database1,database2
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=database
Usernames and passwords will default to the values of POSTGRES_USER
and POSTGRES_PASSWORD
.
postgres:
image: eu.gcr.io/your-project/postgres-multi-db
environment:
- POSTGRES_MULTIPLE_DATABASES=database1:username1:password1,database2:username2,database3
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=database
Missing usernames and passwords will default to the values of POSTGRES_USER
and POSTGRES_PASSWORD
.
The repository is maintained at postgres-multiple-databases.