• Stars
    star
    656
  • Rank 66,495 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Using multiple databases with the official PostgreSQL Docker image

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 *.sh scripts under /docker-entrypoint-initdb.d (creating the directory if necessary). After the entrypoint calls initdb to create the default postgres user and database, it will run any *.sql files 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

By mounting a volume

Clone the repository, mount its directory as a volume into /docker-entrypoint-initdb.d and declare database names separated by commas in POSTGRES_MULTIPLE_DATABASES environment variable as follows (docker-compose syntax):

myapp-postgresql:
    image: postgres:9.6.2
    volumes:
        - ../docker-postgresql-multiple-databases:/docker-entrypoint-initdb.d
    environment:
        - POSTGRES_MULTIPLE_DATABASES: db1,db2
        - POSTGRES_USER: myapp
        - POSTGRES_PASSWORD:

By building a custom image

Clone the repository, build and push the image to your Docker repository, for example for Google Private Repository do the following:

docker build --tag=eu.gcr.io/your-project/postgres-multi-db .
gcloud docker -- push eu.gcr.io/your-project/postgres-multi-db

You still need to pass the POSTGRES_MULTIPLE_DATABASES environment variable to the container:

myapp-postgresql:
    image: eu.gcr.io/your-project/postgres-multi-db
    environment:
        - POSTGRES_MULTIPLE_DATABASES: db1,db2
        - POSTGRES_USER: myapp
        - POSTGRES_PASSWORD:

Non-standard database names

If you need to use non-standard database names (hyphens, uppercase letters etc), quote them in POSTGRES_MULTIPLE_DATABASES:

    environment:
        - POSTGRES_MULTIPLE_DATABASES: "test-db-1","test-db-2"

More Repositories

1

django-admin-list-filter-dropdown

Use dropdowns in Django admin list filter
Python
306
star
2

winforms-mvp

Windows Forms example of the Passive View variant of the Model-View-Presenter pattern
C#
209
star
3

git-svn-bridge

Instructions, scripts and utility programs for synchronizing/mirroring changes between git and Subversion
C#
120
star
4

git-mirror

Scripts for setting up and synchronizing two-way mirroring between two Git repositories
Shell
78
star
5

burp-suite-http-proxy-history-converter

Python script that converts Burp Suite HTTP proxy history files to CSV or HTML
Python
77
star
6

ask-jira

Python app that uses the Jira API for aggregate and complex tasks and reports
Python
41
star
7

migrate-imap-account-to-gmail

Migrate mail from IMAP server account to GMail account
Python
35
star
8

ubuntu-old-kernel-cleanup

Script that helps to remove unused kernels from an Ubuntu (and possibly also Debian) Linux system
Python
21
star
9

django-commands

Management commands for Django: clear database, backup database, load database from backup, clear cache.
Python
17
star
10

burp-suite-http-proxy-history-viewer

Burp Suite HTTP proxy history viewer
Java
15
star
11

flag-set-cpp

flag_set is a type-safe class for using enums as flags in C++
C++
10
star
12

xml-xslt-xsl-fo-dotnet

Example of generating PDF documents in .NET with XML, XSLT, XSL-FO and FO.NET
C#
10
star
13

django-deploy

Automatic remote deployment of Django projects with Fabric as well as environment setup and development process guidelines.
Python
8
star
14

remote-ejb-injection

Sample project for demonstrating inter-artifact communication between artifacts deployed inside the same Java EE application server
Java
6
star
15

vaadin-javaee-jaas-example

Example Vaadin 8 Java EE application that demonstrates how to authenticate and authorize users using JAAS and Vaadin CDI add-on, login form and view navigator
Java
6
star
16

mono-static-linking

Small example of static linking C libraries into applications with Mono
C#
5
star
17

datamapper-cpp

datamapper-cpp is an object-relational mapper for C++ and SQLite
C++
5
star
18

dbc-cpp

Lightweight database access library for C++ with JDBC-like ResultSet interface. Only SQLite driver implemented for now.
C++
4
star
19

plugit

A framework for installing applications. See http://wiki.python.org/moin/ApplicationInfrastructure for specifics.
Python
4
star
20

debugging-cgi-applications-with-gdb

How to debug CGI applications with GDB
C
4
star
21

util-cpp

General utilities useful in C++ development: release assert, lightweight scoped pointer that accepts a deleter and does not depend on Boost, disable copy etc.
C++
3
star
22

docker-python-nodejs-google-chrome

Docker image with latest Python 3, Node.js 12 and stable Google Chrome - and ack
Dockerfile
3
star
23

local-ejb-injection

Sample project demonstrating packaging EJB JARs and WARs into EAR
Java
3
star
24

vaadin-javaee-clinic-patient-queue-example

An example clinic patient queue application using server push, Vaadin 8 and Java EE 8
Java
3
star
25

cve_tracker

Python CVE tracker
Python
2
star
26

tincan

tincan is a C++ ORM for SQLite and a serializer to/from XML that is built on top of a generic object mapping core
C++
2
star
27

docker-cmake-gtest-valgrind-ubuntu

Docker image with CMake, Google Test, Valgrind and C++ build tools
Dockerfile
2
star
28

dotfiles

My dotfiles (vim, bash etc)
Python
2
star
29

docker-python-selenium-xvfb

Dockerfile for building MRTS/PYTHON-SELENIUM-XVFB image with Python, Selenium, Chrome, XVFB, Requests and Records with PostgreSQL and Oracle support
Python
2
star
30

docker-python-spatialite

Docker image with latest Python 3, SpatiaLite and SpatiaLite dependencies (PROJ.4, GEOS, GDAL) suitable for GeoDjango
Dockerfile
2
star
31

validate-git-commit-authors-against-gitlab

Validate Git commit authors against GitLab group members during pushes to Git repository
Python
2
star
32

qparams

Add add_query_params() to urlparse and urllib.parse (details at the homepage URL below)
Python
2
star
33

boost-bootstrap

Script that bootstraps Boost
C++
1
star
34

jira-warden

Python app for tending for JIRA Software issues and sprint boards
Python
1
star
35

algorithm-utils-cpp

High-level utility wrappers around standard algorithms and Boost to make functional programming in C++ easier.
C++
1
star
36

profile

Profiling experiments to use /fastcap optimally in Windows CE
C
1
star
37

docker-java-selenium-xvfb

Dockerfile for building MRTS/JAVA-SELENIUM-XVFB image with OpenJDK, Selenium, Chrome, XVFB and Oracle JDBC support
Java
1
star
38

foodbank-campaign

FoodBank campaing management app built with Django
Python
1
star
39

win32-asyncconnect

Asynchronous host name lookup and socket connection example with win32 Winsock API.
C++
1
star
40

currency-rate-monitor

Python app for monitoring currency rates and configured amount value changes. Sends statistics and a graph with rate history to configured email. Fetches rates from TransferWise.
Python
1
star
41

test-cpp

A lightweight template-based testing framework for C++ that integrates well with Visual Studio.
C++
1
star