Merge ~valentinviennot/ubuntu-docker-images:update-postgresql-readme into ~ubuntu-docker-images/ubuntu-docker-images/+git/postgresql:edge

Proposed by Valentin Viennot
Status: Merged
Merged at revision: e1ac68b9c520ae5f2a83d4ea9e1f34931b0d9f3e
Proposed branch: ~valentinviennot/ubuntu-docker-images:update-postgresql-readme
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/postgresql:edge
Diff against target: 90 lines (+13/-24)
1 file modified
README.md (+13/-24)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Needs Fixing
Richard Harding Pending
Review via email: mp+393908@code.launchpad.net

Description of the change

Fix bug with password & clean/consistency check.

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Valentin. I found a very small nit; let me know when you fix it and I can merge the branch for you.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/README.md b/README.md
index 7e5762b..27591ae 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ SQL:2008 data types, including INTEGER, NUMERIC, BOOLEAN, CHAR, VARCHAR, DATE,
9INTERVAL, and TIMESTAMP. It also supports storage of binary large objects,9INTERVAL, and TIMESTAMP. It also supports storage of binary large objects,
10including pictures, sounds, or video. It has native programming interfaces for10including pictures, sounds, or video. It has native programming interfaces for
11C/C++, Java, .Net, Perl, Python, Ruby, Tcl, ODBC, among others, and exceptional11C/C++, Java, .Net, Perl, Python, Ruby, Tcl, ODBC, among others, and exceptional
12documentation.12documentation. Read more on the [PostgreSQL website](https://www.postgresql.org/docs/).
1313
14## Tags14## Tags
1515
@@ -25,25 +25,14 @@ documentation.
2525
26```sh26```sh
27$ docker network create postgres-net27$ docker network create postgres-net
28# Run the server28$ docker run -d --name postgres-instance --network postgres-net -e TZ=Europe/London -e POSTGRES_PASSWORD=My:s3Cr3t/ squeakywheel/postgres:edge
29$ docker run --name postgres-instance --network postgres-net --env POSTGRES_PASSWORD=My$seCret --detach squeakywheel/postgres:edge
30# Run the client
31$ docker run --interactive --tty --rm --network postgres-net squeakywheel/postgres:edge psql -h postgres-instance -U postgres
32```
33
34The password will be asked and you can enter `My$seCret`. Now, you are logged in and can enjoy your new instance.
35
36Since containers are ephemeral you might be interested in persist data and not initialize a new database every time you launch a new container. To do that you can use docker volumes:
37
38```sh
39$ docker run --name postgres --volume /path/to/persisted/data:/var/lib/postgresql/data squeakywheel/postgres:edge
40```29```
4130
42#### Parameters31#### Parameters
4332
44| Parameter | Description |33| Parameter | Description |
45|---|---|34|---|---|
46| `-e TZ=UTC` | Timezone |35| `-e TZ=UTC` | Timezone. |
47| `-e POSTGRES_PASSWORD=secret` | Set the password for the superuser which is `postgres` by default. Bear in mind that to connect to the database in the same host the password is not needed but to access it via an external host (for instance another container) the password is needed. This option is **mandatory** and **must not be empty**. |36| `-e POSTGRES_PASSWORD=secret` | Set the password for the superuser which is `postgres` by default. Bear in mind that to connect to the database in the same host the password is not needed but to access it via an external host (for instance another container) the password is needed. This option is **mandatory** and **must not be empty**. |
48| `-e POSTGRES_USER=john` | Create a new user with superuser privileges. This is used in conjunction with `POSTGRES_PASSWORD` |37| `-e POSTGRES_USER=john` | Create a new user with superuser privileges. This is used in conjunction with `POSTGRES_PASSWORD` |
49| `-e POSTGRES_DB=db_test` | Set the name of the default database. |38| `-e POSTGRES_DB=db_test` | Set the name of the default database. |
@@ -51,6 +40,9 @@ $ docker run --name postgres --volume /path/to/persisted/data:/var/lib/postgresq
51| `-e POSTGRES_INITDB_WALDIR=/path/to/location` | Set the location of the Postgres transaction log. By default it is stored in a subdirectory of the main Postgres data folder (`PGDATA`). |40| `-e POSTGRES_INITDB_WALDIR=/path/to/location` | Set the location of the Postgres transaction log. By default it is stored in a subdirectory of the main Postgres data folder (`PGDATA`). |
52| `-e POSTGRES_HOST_AUTH_METHOD=trust` | Set the `auth-method` for `host` connections for `all` databases, `all` users, and `all` addresses. The following will be added to the `pg_hba.conf` if this option is passed: `host all all all $POSTGRES_HOST_AUTH_METHOD`. |41| `-e POSTGRES_HOST_AUTH_METHOD=trust` | Set the `auth-method` for `host` connections for `all` databases, `all` users, and `all` addresses. The following will be added to the `pg_hba.conf` if this option is passed: `host all all all $POSTGRES_HOST_AUTH_METHOD`. |
53| `-e PGDATA=/path/to/location` | set the location of the database files. The default is `/var/lib/postgresql/data`. |42| `-e PGDATA=/path/to/location` | set the location of the database files. The default is `/var/lib/postgresql/data`. |
43| `-p 30432:5432` | Expose Postgresql server on `localhost:6032`. |
44| `-v /path/to/postgresql.conf:/etc/postgresql/postgresql.conf` | Pass your own `postgresql.conf` configuration file (download this [example file](https://git.launchpad.net/~canonical-server/ubuntu-server-oci/+git/postgresql/plain/examples/config/postgresql.conf)). |
45| `-v /path/to/persisted/data:/var/lib/postgresql/data` | Persist data instead of initializing a new database every time you launch a new container. |
5446
55#### Initialization Scripts47#### Initialization Scripts
5648
@@ -62,23 +54,20 @@ One can also add initialization scripts to their containers. This includes `*.sq
6254
63All of this is done before the Postgres service is started. Keep in mind if your `PGDATA` directory is not empty (contains pre-existing database) they will be left untouched.55All of this is done before the Postgres service is started. Keep in mind if your `PGDATA` directory is not empty (contains pre-existing database) they will be left untouched.
6456
65#### Database Configuration57#### Testing/Debugging
6658
67You can pass your own configuration file to the container doing the following:59In case you need to debug what it is happening with the container you can run `docker logs <name_of_the_container>`. To get access to an interactive shell run:
6860
69```sh61```sh
70$ docker run --name postgres --volume /path/to/postgres/config/file/postgresql.conf:/etc/postgresql/postgresql.conf --env POSTGRES_PASSWORD=P@sSwd squeakywheel/postgres:edge62$ docker exec -it <name_of_the_container> /bin/bash
71```63```
7264
73#### Debugging65With this same image, you can launch an interactive container as a client to connect to your `postgresql` server running in the first container.
74
75In case you need to debug what it is happening with the container you can run `docker logs <name_of_the_container>`. But if you want to get access to an interactive shell run:
7666
77```sh67```sh
78$ docker exec -it <name_of_the_container> /bin/bash68$ docker run -it --rm --network postgres-net squeakywheel/postgres:edge psql -h postgres-instance -U postgres
79```69```
8070The password will be asked and you can enter `My:s3Cr3t/`. Now, you are logged in and can enjoy your new instance.
81To see how to use the Postgres OCI image with `docker-compose` and `kubernetes` check the `examples/README.md` file.
8271
83## Deploy with Kubernetes72## Deploy with Kubernetes
8473
@@ -134,7 +123,7 @@ spec:
134 image: squeakywheel/postgres:edge123 image: squeakywheel/postgres:edge
135 env:124 env:
136 - name: POSTGRES_PASSWORD125 - name: POSTGRES_PASSWORD
137 value: "myS&cret"126 value: "My:s3Cr3t/"
138 volumeMounts:127 volumeMounts:
139 - name: postgres-config-volume128 - name: postgres-config-volume
140 mountPath: /etc/postgresql/postgresql.conf129 mountPath: /etc/postgresql/postgresql.conf

Subscribers

People subscribed via source and target branches