Skip to content

Commit 45b6449

Browse files
committed
cleanup: updated readme
1 parent 8230d49 commit 45b6449

File tree

1 file changed

+21
-48
lines changed

1 file changed

+21
-48
lines changed

README.md

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,30 @@
11
# Using multiple databases with the official PostgreSQL Docker image
22

3-
The [official recommendation](https://hub.docker.com/_/postgres/) for creating
4-
multiple databases is as follows:
3+
A PostgreSQL docker build that allows the creation of multiple databases in one container
54

6-
*If you would like to do additional initialization in an image derived from
7-
this one, add one or more `*.sql`, `*.sql.gz`, or `*.sh` scripts under
8-
`/docker-entrypoint-initdb.d` (creating the directory if necessary). After the
9-
entrypoint calls `initdb` to create the default `postgres` user and database,
10-
it will run any `*.sql` files and source any `*.sh` scripts found in that
11-
directory to do further initialization before starting the service.*
12-
13-
This directory contains a script to create multiple databases using that
14-
mechanism.
5+
This build uses a script to create additional databases and grants all privileges to the databases to the admin user.
156

167
## Usage
178

18-
### By mounting a volume
19-
20-
Clone the repository, mount its directory as a volume into
21-
`/docker-entrypoint-initdb.d` and declare database names separated by commas in
22-
`POSTGRES_MULTIPLE_DATABASES` environment variable as follows
23-
(`docker-compose` syntax):
24-
25-
myapp-postgresql:
26-
image: postgres:9.6.2
9+
postgres:
10+
restart: always
11+
image: irobbierobinson/multi-db-postgres:latest
2712
volumes:
28-
- ../docker-postgresql-multiple-databases:/docker-entrypoint-initdb.d
29-
environment:
30-
- POSTGRES_MULTIPLE_DATABASES=db1,db2
31-
- POSTGRES_USER=myapp
32-
- POSTGRES_PASSWORD=
33-
34-
### By building a custom image
35-
36-
Clone the repository, build and push the image to your Docker repository,
37-
for example for Google Private Repository do the following:
38-
39-
docker build --tag=eu.gcr.io/your-project/postgres-multi-db .
40-
gcloud docker -- push eu.gcr.io/your-project/postgres-multi-db
41-
42-
You still need to pass the `POSTGRES_MULTIPLE_DATABASES` environment variable
43-
to the container:
44-
45-
myapp-postgresql:
46-
image: eu.gcr.io/your-project/postgres-multi-db
13+
- ./pg-db-data:/var/lib/postgresql/data
4714
environment:
48-
- POSTGRES_MULTIPLE_DATABASES=db1,db2
49-
- POSTGRES_USER=myapp
50-
- POSTGRES_PASSWORD=
15+
- POSTGRES_PASSWORD=postgres
16+
- POSTGRES_USER=postgres
17+
- POSTGRES_DB=postgres
18+
- POSTGRES_ADDITIONAL_DATABASES=db,keycloak
19+
ports:
20+
- 5432:5432
21+
networks:
22+
- backend
23+
24+
## Environment Variables
25+
26+
`POSTGRES_PASSWORD` - Admin Password (default: postgres)
27+
`POSTGRES_USER` - Admin Username (default: postgres)
28+
`POSTGRES_DB` - Default Postgresql DB Name (default: postgres)
29+
`POSTGRES_ADDITIONAL_DATABASES` - Additional databases that will be created alongside the default (separated by commas).
5130

52-
### Non-standard database names
53-
54-
If you need to use non-standard database names (hyphens, uppercase letters etc), quote them in `POSTGRES_MULTIPLE_DATABASES`:
55-
56-
environment:
57-
- POSTGRES_MULTIPLE_DATABASES="test-db-1","test-db-2"

0 commit comments

Comments
 (0)