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
1diff --git a/README.md b/README.md
2index 7e5762b..27591ae 100644
3--- a/README.md
4+++ b/README.md
5@@ -9,7 +9,7 @@ SQL:2008 data types, including INTEGER, NUMERIC, BOOLEAN, CHAR, VARCHAR, DATE,
6 INTERVAL, and TIMESTAMP. It also supports storage of binary large objects,
7 including pictures, sounds, or video. It has native programming interfaces for
8 C/C++, Java, .Net, Perl, Python, Ruby, Tcl, ODBC, among others, and exceptional
9-documentation.
10+documentation. Read more on the [PostgreSQL website](https://www.postgresql.org/docs/).
11
12 ## Tags
13
14@@ -25,25 +25,14 @@ documentation.
15
16 ```sh
17 $ docker network create postgres-net
18-# Run the server
19-$ docker run --name postgres-instance --network postgres-net --env POSTGRES_PASSWORD=My$seCret --detach squeakywheel/postgres:edge
20-# Run the client
21-$ docker run --interactive --tty --rm --network postgres-net squeakywheel/postgres:edge psql -h postgres-instance -U postgres
22-```
23-
24-The password will be asked and you can enter `My$seCret`. Now, you are logged in and can enjoy your new instance.
25-
26-Since 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:
27-
28-```sh
29-$ docker run --name postgres --volume /path/to/persisted/data:/var/lib/postgresql/data squeakywheel/postgres:edge
30+$ docker run -d --name postgres-instance --network postgres-net -e TZ=Europe/London -e POSTGRES_PASSWORD=My:s3Cr3t/ squeakywheel/postgres:edge
31 ```
32
33 #### Parameters
34
35 | Parameter | Description |
36 |---|---|
37-| `-e TZ=UTC` | Timezone |
38+| `-e TZ=UTC` | Timezone. |
39 | `-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**. |
40 | `-e POSTGRES_USER=john` | Create a new user with superuser privileges. This is used in conjunction with `POSTGRES_PASSWORD` |
41 | `-e POSTGRES_DB=db_test` | Set the name of the default database. |
42@@ -51,6 +40,9 @@ $ docker run --name postgres --volume /path/to/persisted/data:/var/lib/postgresq
43 | `-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`). |
44 | `-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`. |
45 | `-e PGDATA=/path/to/location` | set the location of the database files. The default is `/var/lib/postgresql/data`. |
46+| `-p 30432:5432` | Expose Postgresql server on `localhost:6032`. |
47+| `-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)). |
48+| `-v /path/to/persisted/data:/var/lib/postgresql/data` | Persist data instead of initializing a new database every time you launch a new container. |
49
50 #### Initialization Scripts
51
52@@ -62,23 +54,20 @@ One can also add initialization scripts to their containers. This includes `*.sq
53
54 All 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.
55
56-#### Database Configuration
57+#### Testing/Debugging
58
59-You can pass your own configuration file to the container doing the following:
60+In 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:
61
62 ```sh
63-$ docker run --name postgres --volume /path/to/postgres/config/file/postgresql.conf:/etc/postgresql/postgresql.conf --env POSTGRES_PASSWORD=P@sSwd squeakywheel/postgres:edge
64+$ docker exec -it <name_of_the_container> /bin/bash
65 ```
66
67-#### Debugging
68-
69-In 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:
70+With this same image, you can launch an interactive container as a client to connect to your `postgresql` server running in the first container.
71
72 ```sh
73-$ docker exec -it <name_of_the_container> /bin/bash
74+$ docker run -it --rm --network postgres-net squeakywheel/postgres:edge psql -h postgres-instance -U postgres
75 ```
76-
77-To see how to use the Postgres OCI image with `docker-compose` and `kubernetes` check the `examples/README.md` file.
78+The password will be asked and you can enter `My:s3Cr3t/`. Now, you are logged in and can enjoy your new instance.
79
80 ## Deploy with Kubernetes
81
82@@ -134,7 +123,7 @@ spec:
83 image: squeakywheel/postgres:edge
84 env:
85 - name: POSTGRES_PASSWORD
86- value: "myS&cret"
87+ value: "My:s3Cr3t/"
88 volumeMounts:
89 - name: postgres-config-volume
90 mountPath: /etc/postgresql/postgresql.conf

Subscribers

People subscribed via source and target branches