Skip to content

Commit 0860eb4

Browse files
committed
README.md: make sure the readme file is distributed
1 parent 8de9607 commit 0860eb4

File tree

6 files changed

+232
-218
lines changed

6 files changed

+232
-218
lines changed

9.2/README.md

-98
This file was deleted.

9.2/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
root/usr/share/container-scripts/postgresql/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
PostgreSQL Docker image
2+
=======================
3+
4+
This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
5+
Users can choose between RHEL and CentOS based images.
6+
7+
8+
Environment variables and volumes
9+
----------------------------------
10+
11+
The image recognizes the following environment variables that you can set during
12+
initialization by passing `-e VAR=VALUE` to the Docker run command.
13+
14+
| Variable name | Description |
15+
| :--------------------------- | ---------------------------------------------- |
16+
| `POSTGRESQL_USER` | User name for PostgreSQL account to be created |
17+
| `POSTGRESQL_PASSWORD` | Password for the user account |
18+
| `POSTGRESQL_DATABASE` | Database name |
19+
| `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional) |
20+
21+
The following environment variables influence the PostgreSQL configuration file. They are all optional.
22+
23+
| Variable name | Description | Default
24+
| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
25+
| `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed. This also sets the maximum number of prepared transactions. | 100
26+
| `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections | 0
27+
| `POSTGRESQL_SHARED_BUFFERS` | Sets how much memory is dedicated to PostgreSQL to use for caching data | 32M
28+
| `POSTGRESQL_EFFECTIVE_CACHE_SIZE` | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself | 128M
29+
30+
You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
31+
32+
| Volume mount point | Description |
33+
| :----------------------- | ------------------------------------- |
34+
| `/var/lib/pgsql/data` | PostgreSQL database cluster directory |
35+
36+
**Notice: When mouting a directory from the host into the container, ensure that the mounted
37+
directory has the appropriate permissions and that the owner and group of the directory
38+
matches the user UID or name which is running inside the container.**
39+
40+
Usage
41+
----------------------
42+
43+
For this, we will assume that you are using the `centos/postgresql-94-centos7` image.
44+
If you want to set only the mandatory environment variables and not store the database
45+
in a host directory, execute the following command:
46+
47+
```
48+
$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-94-centos7
49+
```
50+
51+
This will create a container named `postgresql_database` running PostgreSQL with
52+
database `db` and user with credentials `user:pass`. Port 5432 will be exposed
53+
and mapped to the host. If you want your database to be persistent across container
54+
executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
55+
the PostgreSQL database cluster directory.
56+
57+
If the database cluster directory is not initialized, the entrypoint script will
58+
first run [`initdb`](http://www.postgresql.org/docs/9.4/static/app-initdb.html)
59+
and setup necessary database users and passwords. After the database is initialized,
60+
or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.4/static/app-postgres.html)
61+
is executed and will run as PID 1. You can stop the detached container by running
62+
`docker stop postgresql_database`.
63+
64+
PostgreSQL auto-tuning
65+
--------------------
66+
67+
When the PostgreSQL image is run with the `--memory` parameter set and if there
68+
are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
69+
`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
70+
based on the value provided in the `--memory` parameter.
71+
72+
The values are calculated based on the
73+
[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
74+
formulas. For the `shared_buffers` we use 1/4 of given memory and for the
75+
`effective_cache_size` we set the value to 1/2 of the given memory.
76+
77+
PostgreSQL admin account
78+
------------------------
79+
The admin account `postgres` has no password set by default, only allowing local
80+
connections. You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
81+
variable when initializing your container. This will allow you to login to the
82+
`postgres` account remotely. Local connections will still not require a password.
83+
84+
85+
Changing passwords
86+
------------------
87+
88+
Since passwords are part of the image configuration, the only supported method
89+
to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
90+
admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
91+
`POSTGRESQL_ADMIN_PASSWORD`, respectively.
92+
93+
Changing database passwords through SQL statements or any way other than through
94+
the environment variables aforementioned will cause a mismatch between the
95+
values stored in the variables and the actual passwords. Whenever a database
96+
container starts it will reset the passwords to the values stored in the
97+
environment variables.
98+

9.2/root/usr/share/container-scripts/postgresql/common.sh

+17-11
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,23 @@ function usage() {
3636
if [ $# == 1 ]; then
3737
echo >&2 "error: $1"
3838
fi
39-
echo >&2 "You must either specify the following environment variables:"
40-
echo >&2 " POSTGRESQL_USER (regex: '$psql_identifier_regex')"
41-
echo >&2 " POSTGRESQL_PASSWORD (regex: '$psql_password_regex')"
42-
echo >&2 " POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')"
43-
echo >&2 "Or the following environment variable:"
44-
echo >&2 " POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')"
45-
echo >&2 "Or both."
46-
echo >&2 "Optional settings:"
47-
echo >&2 " POSTGRESQL_MAX_CONNECTIONS (default: 100)"
48-
echo >&2 " POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)"
49-
echo >&2 " POSTGRESQL_SHARED_BUFFERS (default: 32MB)"
39+
40+
cat >&2 <<EOF
41+
You must either specify the following environment variables:
42+
POSTGRESQL_USER (regex: '$psql_identifier_regex')
43+
POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
44+
POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
45+
Or the following environment variable:
46+
POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
47+
Or both.
48+
Optional settings:
49+
POSTGRESQL_MAX_CONNECTIONS (default: 100)
50+
POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
51+
POSTGRESQL_SHARED_BUFFERS (default: 32MB)
52+
53+
For more information see /usr/share/container-scripts/postgresql/README.md
54+
within the container or visit https://github.com/openshift/postgresql.
55+
EOF
5056
exit 1
5157
}
5258

9.4/README.md

-98
This file was deleted.

9.4/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
root/usr/share/container-scripts/postgresql/README.md

0 commit comments

Comments
 (0)