Skip to content

Commit 60370d5

Browse files
author
Sameer Naik
committed
Merge pull request #15 from sameersbn/finalize-interface
Finalize interface
2 parents 9c49966 + 644335d commit 60370d5

File tree

6 files changed

+256
-256
lines changed

6 files changed

+256
-256
lines changed

README.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# TLDR
88

99
```bash
10-
docker run --name postgresql -e POSTGRESQL_PASSWORD=password123 bitnami/postgresql
10+
docker run --name postgresql -e POSTGRES_PASSWORD=password123 bitnami/postgresql
1111
```
1212

1313
## Docker Compose
@@ -16,7 +16,7 @@ docker run --name postgresql -e POSTGRESQL_PASSWORD=password123 bitnami/postgres
1616
postgresql:
1717
image: bitnami/postgresql
1818
environment:
19-
- POSTGRESQL_PASSWORD=password123
19+
- POSTGRES_PASSWORD=password123
2020
```
2121

2222
# Get this image
@@ -76,7 +76,7 @@ The first step is to start our PostgreSQL server.
7676
Docker's linking system uses container ids or names to reference containers. We can explicitly specify a name for our PostgreSQL server to make it easier to connect to other containers.
7777

7878
```bash
79-
docker run --name postgresql -e POSTGRESQL_PASSWORD=password123 bitnami/postgresql
79+
docker run --name postgresql -e POSTGRES_PASSWORD=password123 bitnami/postgresql
8080
```
8181

8282
### Step 2: Run PostgreSQL image as a client and link to our server
@@ -108,7 +108,7 @@ Copy the snippet below into your `docker-compose.yml` to add PostgreSQL to your
108108
postgresql:
109109
image: bitnami/postgresql
110110
environment:
111-
- POSTGRESQL_PASSWORD=password123
111+
- POSTGRES_PASSWORD=password123
112112
```
113113

114114
### Step 2: Link it to another container in your application
@@ -128,10 +128,10 @@ Inside `myapp`, use `postgresql` as the hostname for the PostgreSQL server.
128128

129129
## Setting the root password on first run
130130

131-
In the above commands you may have noticed the use of the `POSTGRESQL_PASSWORD` environment variable. Passing the `POSTGRESQL_PASSWORD` environment variable when running the image for the first time will set the password of the `postgres` user to the value of `POSTGRESQL_PASSWORD`.
131+
In the above commands you may have noticed the use of the `POSTGRES_PASSWORD` environment variable. Passing the `POSTGRES_PASSWORD` environment variable when running the image for the first time will set the password of the `postgres` user to the value of `POSTGRES_PASSWORD`.
132132

133133
```bash
134-
docker run --name postgresql -e POSTGRESQL_PASSWORD=password123 bitnami/postgresql
134+
docker run --name postgresql -e POSTGRES_PASSWORD=password123 bitnami/postgresql
135135
```
136136

137137
or using Docker Compose:
@@ -140,18 +140,18 @@ or using Docker Compose:
140140
postgresql:
141141
image: bitnami/postgresql
142142
environment:
143-
- POSTGRESQL_PASSWORD=password123
143+
- POSTGRES_PASSWORD=password123
144144
```
145145

146146
**Note!**
147147
The `postgres` user is a superuser and has full administrative access to the PostgreSQL database.
148148

149149
## Creating a database on first run
150150

151-
By passing the `POSTGRESQL_DATABASE` environment variable when running the image for the first time, a database will be created. This is useful if your application requires that a database already exists, saving you from having to manually create the database using the PostgreSQL client.
151+
By passing the `POSTGRES_DB` environment variable when running the image for the first time, a database will be created. This is useful if your application requires that a database already exists, saving you from having to manually create the database using the PostgreSQL client.
152152

153153
```bash
154-
docker run --name postgresql -e POSTGRESQL_DATABASE=my_database bitnami/postgresql
154+
docker run --name postgresql -e POSTGRES_DB=my_database bitnami/postgresql
155155
```
156156

157157
or using Docker Compose:
@@ -160,15 +160,15 @@ or using Docker Compose:
160160
postgresql:
161161
image: bitnami/postgresql
162162
environment:
163-
- POSTGRESQL_DATABASE=my_database
163+
- POSTGRES_DB=my_database
164164
```
165165

166166
## Creating a database user on first run
167167

168-
You can also create a restricted database user that only has permissions for the database created with the [`POSTGRESQL_DATABASE`](#creating-a-database-on-first-run) environment variable. To do this, provide the `POSTGRESQL_USER` environment variable.
168+
You can also create a restricted database user that only has permissions for the database created with the [`POSTGRES_DB`](#creating-a-database-on-first-run) environment variable. To do this, provide the `POSTGRES_USER` environment variable.
169169

170170
```bash
171-
docker run --name postgresql -e POSTGRESQL_USER=my_user -e POSTGRESQL_PASSWORD=password123 -e POSTGRESQL_DATABASE=my_database bitnami/postgresql
171+
docker run --name postgresql -e POSTGRES_USER=my_user -e POSTGRES_PASSWORD=password123 -e POSTGRES_DB=my_database bitnami/postgresql
172172
```
173173

174174
or using Docker Compose:
@@ -177,23 +177,23 @@ or using Docker Compose:
177177
postgresql:
178178
image: bitnami/postgresql
179179
environment:
180-
- POSTGRESQL_USER=my_user
181-
- POSTGRESQL_PASSWORD=password123
182-
- POSTGRESQL_DATABASE=my_database
180+
- POSTGRES_USER=my_user
181+
- POSTGRES_PASSWORD=password123
182+
- POSTGRES_DB=my_database
183183
```
184184

185185
**Note!**
186-
When `POSTGRESQL_USER` is is specified, the `postgres` user is not assigned a password and as a result you cannot login remotely to the PostgreSQL server as the `postgres` user.
186+
When `POSTGRES_USER` is is specified, the `postgres` user is not assigned a password and as a result you cannot login remotely to the PostgreSQL server as the `postgres` user.
187187

188188
## Setting up a streaming replication
189189

190190
A [Streaming replication](http://www.postgresql.org/docs/9.4/static/warm-standby.html#STREAMING-REPLICATION) cluster can easily be setup with the Bitnami PostgreSQL Docker Image using the following environment variables:
191191

192-
- `POSTGRESQL_REPLICATION_MODE`: Replication mode. Possible values `master`/`slave` (default: master).
193-
- `POSTGRESQL_REPLICATION_USER`: Replication user. User is created on the master at first boot (default: none).
194-
- `POSTGRESQL_REPLICATION_PASSWORD`: Replication users password. Password is set for `POSTGRESQL_REPLICATION_USER` on master on the first boot (default: none).
195-
- `POSTGRESQL_MASTER_HOST`: Hostname/IP of replication master (parameter available only on slave).
196-
- `POSTGRESQL_MASTER_PORT`: Port of replication master, defaults to `5432` (parameter available only on slave).
192+
- `POSTGRES_MODE`: Replication mode. Possible values `master`/`slave` (default: master).
193+
- `POSTGRES_REPLICATION_USER`: Replication user. User is created on the master at first boot (default: none).
194+
- `POSTGRES_REPLICATION_PASSWORD`: Replication users password. Password is set for `POSTGRES_REPLICATION_USER` on master on the first boot (default: none).
195+
- `POSTGRES_MASTER_HOST`: Hostname/IP of replication master (parameter available only on slave).
196+
- `POSTGRES_MASTER_PORT`: Port of replication master, defaults to `5432` (parameter available only on slave).
197197

198198
In a replication cluster you can have one master and zero or more slaves. Our default configuration allows a maximum of 16 slaves, you can change it in `postgresql.conf` if required.
199199

@@ -205,18 +205,18 @@ The first step is to start the master.
205205

206206
```bash
207207
docker run --name postgresql-master \
208-
-e POSTGRESQL_USER=my_user \
209-
-e POSTGRESQL_PASSWORD=password123 \
210-
-e POSTGRESQL_DATABASE=my_database \
211-
-e POSTGRESQL_REPLICATION_MODE=master \
212-
-e POSTGRESQL_REPLICATION_USER=my_repl_user \
213-
-e POSTGRESQL_REPLICATION_PASSWORD=my_repl_password \
208+
-e POSTGRES_USER=my_user \
209+
-e POSTGRES_PASSWORD=password123 \
210+
-e POSTGRES_DB=my_database \
211+
-e POSTGRES_MODE=master \
212+
-e POSTGRES_REPLICATION_USER=my_repl_user \
213+
-e POSTGRES_REPLICATION_PASSWORD=my_repl_password \
214214
bitnami/postgresql
215215
```
216216

217-
In this command we are configuring the container as the master using the `POSTGRESQL_REPLICATION_MODE=master` parameter. Using the `POSTGRESQL_REPLICATION_USER` and `POSTGRESQL_REPLICATION_PASSWORD` parameters we are creating a replication user that will be used by the slaves to connect to the master and perform streaming replication.
217+
In this command we are configuring the container as the master using the `POSTGRES_MODE=master` parameter. Using the `POSTGRES_REPLICATION_USER` and `POSTGRES_REPLICATION_PASSWORD` parameters we are creating a replication user that will be used by the slaves to connect to the master and perform streaming replication.
218218

219-
By default a container is configured as a `master`. As a result you can drop the `POSTGRESQL_REPLICATION_MODE=master` from the above command.
219+
By default a container is configured as a `master`. As a result you can drop the `POSTGRES_MODE=master` from the above command.
220220

221221
### Step 2: Create the replication slave
222222

@@ -225,29 +225,29 @@ Next we start a replication slave container.
225225
```bash
226226
docker run --name postgresql-slave \
227227
--link postgresql-master:master \
228-
-e POSTGRESQL_MASTER_HOST=master \
229-
-e POSTGRESQL_MASTER_PORT=5432 \
230-
-e POSTGRESQL_REPLICATION_MODE=slave \
231-
-e POSTGRESQL_REPLICATION_USER=my_repl_user \
232-
-e POSTGRESQL_REPLICATION_PASSWORD=my_repl_password \
228+
-e POSTGRES_MASTER_HOST=master \
229+
-e POSTGRES_MASTER_PORT=5432 \
230+
-e POSTGRES_MODE=slave \
231+
-e POSTGRES_REPLICATION_USER=my_repl_user \
232+
-e POSTGRES_REPLICATION_PASSWORD=my_repl_password \
233233
bitnami/postgresql
234234
```
235235

236-
In this command we are configuring the container as a slave using the `POSTGRESQL_REPLICATION_MODE=slave` parameter. Before the replication slave is started, the `POSTGRESQL_MASTER_HOST` and `POSTGRESQL_MASTER_PORT` parameters are used by the slave container to connect to the master and replicate the initial database from the master. The `POSTGRESQL_REPLICATION_USER` and `POSTGRESQL_REPLICATION_PASSWORD` credentials are used to authenticate with the master.
236+
In this command we are configuring the container as a slave using the `POSTGRES_MODE=slave` parameter. Before the replication slave is started, the `POSTGRES_MASTER_HOST` and `POSTGRES_MASTER_PORT` parameters are used by the slave container to connect to the master and replicate the initial database from the master. The `POSTGRES_REPLICATION_USER` and `POSTGRES_REPLICATION_PASSWORD` credentials are used to authenticate with the master.
237237

238238
Using the `master` docker link alias, the Bitnami PostgreSQL Docker image automatically fetches the replication paramaters from the master container, namely:
239239

240-
- `POSTGRESQL_MASTER_HOST`
241-
- `POSTGRESQL_MASTER_PORT`
242-
- `POSTGRESQL_REPLICATION_USER`
243-
- `POSTGRESQL_REPLICATION_PASSWORD`
240+
- `POSTGRES_MASTER_HOST`
241+
- `POSTGRES_MASTER_PORT`
242+
- `POSTGRES_REPLICATION_USER`
243+
- `POSTGRES_REPLICATION_PASSWORD`
244244

245245
As a result you can drop all of these parameters from the slave.
246246

247247
```bash
248248
docker run --name postgresql-slave \
249249
--link postgresql-master:master \
250-
-e POSTGRESQL_REPLICATION_MODE=slave \
250+
-e POSTGRES_MODE=slave \
251251
bitnami/postgresql
252252
```
253253

@@ -269,19 +269,19 @@ With Docker Compose the master-slave replication can be setup using:
269269
master:
270270
image: bitnami/postgresql
271271
environment:
272-
- POSTGRESQL_USER=my_user
273-
- POSTGRESQL_PASSWORD=password123
274-
- POSTGRESQL_DATABASE=my_database
275-
- POSTGRESQL_REPLICATION_MODE=master
276-
- POSTGRESQL_REPLICATION_USER=my_repl_user
277-
- POSTGRESQL_REPLICATION_PASSWORD=my_repl_password
272+
- POSTGRES_USER=my_user
273+
- POSTGRES_PASSWORD=password123
274+
- POSTGRES_DB=my_database
275+
- POSTGRES_MODE=master
276+
- POSTGRES_REPLICATION_USER=my_repl_user
277+
- POSTGRES_REPLICATION_PASSWORD=my_repl_password
278278

279279
slave:
280280
image: bitnami/postgresql
281281
links:
282282
- master:master
283283
environment:
284-
- POSTGRESQL_REPLICATION_MODE=slave
284+
- POSTGRES_MODE=slave
285285
```
286286
287287
Scale the number of slaves using:

help.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
$BITNAMI_APP_NAME cheatsheet:
22

33
ENVIRONMENT VARIABLES:
4-
POSTGRESQL_USER: User to be created on first boot (default: postgres).
5-
POSTGRESQL_PASSWORD: Password to be set for POSTGRESQL_USER on first boot (default: none).
6-
POSTGRESQL_DATABASE: Database to be created on first boot, accessible by POSTGRESQL_USER (default: none).
7-
POSTGRESQL_REPLICATION_MODE: Replication mode. Possible values master/slave (default: master).
8-
POSTGRESQL_REPLICATION_USER: Replication user. User is created on the master at first boot (default: none).
9-
POSTGRESQL_REPLICATION_PASSWORD: Replication users password. Password is set for POSTGRESQL_REPLICATION_USER on master on the first boot (default: none).
10-
POSTGRESQL_MASTER_HOST: Hostname/IP of replication master (parameter available only on slave).
11-
POSTGRESQL_MASTER_PORT: Port of replication master, defaults to 5432 (parameter available only on slave).
4+
POSTGRES_USER: User to be created on first boot (default: postgres).
5+
POSTGRES_PASSWORD: Password to be set for POSTGRES_USER on first boot (default: none).
6+
POSTGRES_DB: Database to be created on first boot, accessible by POSTGRES_USER (default: none).
7+
POSTGRES_MODE: Replication mode. Possible values master/slave (default: master).
8+
POSTGRES_REPLICATION_USER: Replication user. User is created on the master at first boot (default: none).
9+
POSTGRES_REPLICATION_PASSWORD: Replication users password. Password is set for POSTGRES_REPLICATION_USER on master on the first boot (default: none).
10+
POSTGRES_MASTER_HOST: Hostname/IP of replication master (parameter available only on slave).
11+
POSTGRES_MASTER_PORT: Port of replication master, defaults to 5432 (parameter available only on slave).
1212

1313
VOLUMES:
1414
$BITNAMI_APP_VOL_PREFIX/data: Location of $BITNAMI_APP_NAME data files.
@@ -20,7 +20,7 @@
2020

2121
MISC:
2222
Options: You can add extra options during the docker run using the -- prefix.
23-
Note: POSTGRESQL_USER works in conjunction with POSTGRESQL_DATABASE environment variable.
23+
Note: POSTGRES_USER works in conjunction with POSTGRES_DB environment variable.
2424
Tip: Back up the $BITNAMI_APP_VOL_PREFIX/data and $BITNAMI_APP_VOL_PREFIX/conf directories regularly.
2525

2626
COMMANDS:

help.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
environment_variables:
2-
POSTGRESQL_USER: "User to be created on first boot (default: postgres)."
3-
POSTGRESQL_PASSWORD: "Password to be set for POSTGRESQL_USER on first boot (default: none)."
4-
POSTGRESQL_DATABASE: "Database to be created on first boot, accessible by POSTGRESQL_USER (default: none)."
5-
POSTGRESQL_REPLICATION_MODE: "Replication mode. Possible values master/slave (default: master)."
6-
POSTGRESQL_REPLICATION_USER: "Replication user. User is created on the master at first boot (default: none)."
7-
POSTGRESQL_REPLICATION_PASSWORD: "Replication users password. Password is set for POSTGRESQL_REPLICATION_USER on master on the first boot (default: none)."
8-
POSTGRESQL_MASTER_HOST: "Hostname/IP of replication master (parameter available only on slave)."
9-
POSTGRESQL_MASTER_PORT: "Port of replication master, defaults to 5432 (parameter available only on slave)."
2+
POSTGRES_USER: "User to be created on first boot (default: postgres)."
3+
POSTGRES_PASSWORD: "Password to be set for POSTGRES_USER on first boot (default: none)."
4+
POSTGRES_DB: "Database to be created on first boot, accessible by POSTGRES_USER (default: none)."
5+
POSTGRES_MODE: "Replication mode. Possible values master/slave (default: master)."
6+
POSTGRES_REPLICATION_USER: "Replication user. User is created on the master at first boot (default: none)."
7+
POSTGRES_REPLICATION_PASSWORD: "Replication users password. Password is set for POSTGRES_REPLICATION_USER on master on the first boot (default: none)."
8+
POSTGRES_MASTER_HOST: "Hostname/IP of replication master (parameter available only on slave)."
9+
POSTGRES_MASTER_PORT: "Port of replication master, defaults to 5432 (parameter available only on slave)."
1010
volumes:
1111
$BITNAMI_APP_VOL_PREFIX/data: "Location of $BITNAMI_APP_NAME data files."
1212
$BITNAMI_APP_VOL_PREFIX/conf: "Location of $BITNAMI_APP_NAME config files."
@@ -16,5 +16,5 @@ ports:
1616
misc:
1717
Options: "You can add extra options during the docker run using the -- prefix."
1818
Note: "The user and database creation happens only the first time you run the container."
19-
Note: "POSTGRESQL_USER works in conjunction with POSTGRESQL_DATABASE environment variable."
19+
Note: "POSTGRES_USER works in conjunction with POSTGRES_DB environment variable."
2020
Tip: "Back up the $BITNAMI_APP_VOL_PREFIX/data and $BITNAMI_APP_VOL_PREFIX/conf directories regularly."

0 commit comments

Comments
 (0)