Thanks to visit codestin.com
Credit goes to github.com

Skip to content

iqz-systems/docker-postgresql-multiple-databases

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Using multiple databases with the official PostgreSQL Docker image

The official recommendation for creating multiple databases is as follows:

If you would like to do additional initialization in an image derived from this one, add one or more `.sql,.sql.gz, or.shscripts under/docker-entrypoint-initdb.d(creating the directory if necessary). After the entrypoint callsinitdbto create the defaultpostgresuser and database, it will run any.sqlfiles and source any.sh` scripts found in that directory to do further initialization before starting the service.*

This directory contains a script to create multiple databases using that mechanism.

Usage

Open docker-compose.yml file and edit the POSTGRES_MULTIPLE_DATABASES environment variable with a list of db names you'd like to be created in the postgres container. The db names should be comma(,) separated.

Save the file and simpy run:

docker-compose up

to get the container up and running. Your databases would automatically be created and will be exposed by default on port 5432.

Credits

Thanks to @mrts for the inspiration and original script.

About

Using multiple databases with the official PostgreSQL Docker image

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%