You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -76,7 +76,7 @@ The first step is to start our PostgreSQL server.
76
76
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.
77
77
78
78
```bash
79
-
docker run --name postgresql -e POSTGRESQL_PASSWORD=password123 bitnami/postgresql
79
+
docker run --name postgresql -e POSTGRES_PASSWORD=password123 bitnami/postgresql
80
80
```
81
81
82
82
### 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
108
108
postgresql:
109
109
image: bitnami/postgresql
110
110
environment:
111
-
- POSTGRESQL_PASSWORD=password123
111
+
- POSTGRES_PASSWORD=password123
112
112
```
113
113
114
114
### 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.
128
128
129
129
## Setting the root password on first run
130
130
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`.
132
132
133
133
```bash
134
-
docker run --name postgresql -e POSTGRESQL_PASSWORD=password123 bitnami/postgresql
134
+
docker run --name postgresql -e POSTGRES_PASSWORD=password123 bitnami/postgresql
135
135
```
136
136
137
137
or using Docker Compose:
@@ -140,18 +140,18 @@ or using Docker Compose:
140
140
postgresql:
141
141
image: bitnami/postgresql
142
142
environment:
143
-
- POSTGRESQL_PASSWORD=password123
143
+
- POSTGRES_PASSWORD=password123
144
144
```
145
145
146
146
**Note!**
147
147
The `postgres` user is a superuser and has full administrative access to the PostgreSQL database.
148
148
149
149
## Creating a database on first run
150
150
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.
152
152
153
153
```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
155
155
```
156
156
157
157
or using Docker Compose:
@@ -160,15 +160,15 @@ or using Docker Compose:
160
160
postgresql:
161
161
image: bitnami/postgresql
162
162
environment:
163
-
- POSTGRESQL_DATABASE=my_database
163
+
- POSTGRES_DB=my_database
164
164
```
165
165
166
166
## Creating a database user on first run
167
167
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.
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.
187
187
188
188
## Setting up a streaming replication
189
189
190
190
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:
191
191
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).
197
197
198
198
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.
199
199
@@ -205,18 +205,18 @@ The first step is to start the master.
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.
218
218
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.
220
220
221
221
### Step 2: Create the replication slave
222
222
@@ -225,29 +225,29 @@ Next we start a replication slave container.
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.
237
237
238
238
Using the `master` docker link alias, the Bitnami PostgreSQL Docker image automatically fetches the replication paramaters from the master container, namely:
239
239
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`
244
244
245
245
As a result you can drop all of these parameters from the slave.
246
246
247
247
```bash
248
248
docker run --name postgresql-slave \
249
249
--link postgresql-master:master \
250
-
-e POSTGRESQL_REPLICATION_MODE=slave \
250
+
-e POSTGRES_MODE=slave \
251
251
bitnami/postgresql
252
252
```
253
253
@@ -269,19 +269,19 @@ With Docker Compose the master-slave replication can be setup using:
Copy file name to clipboardExpand all lines: help.txt
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
$BITNAMI_APP_NAME cheatsheet:
2
2
3
3
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).
12
12
13
13
VOLUMES:
14
14
$BITNAMI_APP_VOL_PREFIX/data: Location of $BITNAMI_APP_NAME data files.
@@ -20,7 +20,7 @@
20
20
21
21
MISC:
22
22
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.
24
24
Tip: Back up the $BITNAMI_APP_VOL_PREFIX/data and $BITNAMI_APP_VOL_PREFIX/conf directories regularly.
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)."
10
10
volumes:
11
11
$BITNAMI_APP_VOL_PREFIX/data: "Location of $BITNAMI_APP_NAME data files."
12
12
$BITNAMI_APP_VOL_PREFIX/conf: "Location of $BITNAMI_APP_NAME config files."
@@ -16,5 +16,5 @@ ports:
16
16
misc:
17
17
Options: "You can add extra options during the docker run using the -- prefix."
18
18
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."
20
20
Tip: "Back up the $BITNAMI_APP_VOL_PREFIX/data and $BITNAMI_APP_VOL_PREFIX/conf directories regularly."
0 commit comments