Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PostgreSQL to 16 and Upgrade base ubuntu to noble-20240429 #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM ubuntu:jammy-20230605 AS add-apt-repositories
FROM ubuntu:noble-20240429 AS add-apt-repositories

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y wget gnupg \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main' >> /etc/apt/sources.list
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg main' >> /etc/apt/sources.list

FROM ubuntu:jammy-20230605
FROM ubuntu:noble-20240429

LABEL maintainer="[email protected]"

ENV PG_APP_HOME="/etc/docker-postgresql" \
PG_VERSION=15 \
PG_VERSION=16 \
PG_USER=postgres \
PG_HOME=/var/lib/postgresql \
PG_RUNDIR=/run/postgresql \
Expand Down
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# sameersbn/postgresql:15-20230628
# sameersbn/postgresql:16-20240429

- [sameersbn/postgresql:16-20240429](#sameersbnpostgresql16-20240429)
- [Introduction](#introduction)
- [Contributing](#contributing)
- [Issues](#issues)
Expand All @@ -12,14 +13,14 @@
- [Creating database user](#creating-database-user)
- [Creating databases](#creating-databases)
- [Granting user access to a database](#granting-user-access-to-a-database)
- [Enabling extensions](#enabling-extensions)
- [Enabling extensions](#enabling-extensions)
- [Creating replication user](#creating-replication-user)
- [Setting up a replication cluster](#setting-up-a-replication-cluster)
- [Creating a snapshot](#creating-a-snapshot)
- [Creating a backup](#creating-a-backup)
- [Command-line arguments](#command-line-arguments)
- [Logs](#logs)
- [UID/GID mapping](#uidgid-mapping)
- [UID/GID mapping](#uidgid-mapping)
- [Maintenance](#maintenance)
- [Upgrading](#upgrading)
- [Shell Access](#shell-access)
Expand Down Expand Up @@ -59,7 +60,7 @@ Automated builds of the image are available on [Dockerhub](https://hub.docker.co
> **Note**: Builds are also available on [Quay.io](https://quay.io/repository/sameersbn/postgresql)

```bash
docker pull sameersbn/postgresql:15-20230628
docker pull sameersbn/postgresql:16-20240429
```

Alternatively you can build the image yourself.
Expand All @@ -76,7 +77,7 @@ Start PostgreSQL using:
docker run --name postgresql -itd --restart always \
--publish 5432:5432 \
--volume postgresql:/var/lib/postgresql \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

Login to the PostgreSQL server using:
Expand Down Expand Up @@ -107,7 +108,7 @@ By default connections to the PostgreSQL server need to authenticated using a pa
```bash
docker run --name postgresql -itd --restart always \
--env 'PG_TRUST_LOCALNET=true' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

> **Note**
Expand All @@ -121,7 +122,7 @@ By default the `postgres` user is not assigned a password and as a result you ca
```bash
docker run --name postgresql -itd --restart always \
--env 'PG_PASSWORD=passw0rd' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```


Expand All @@ -137,7 +138,7 @@ A new PostgreSQL database user can be created by specifying the `DB_USER` and `D
```bash
docker run --name postgresql -itd --restart always \
--env 'DB_USER=dbuser' --env 'DB_PASS=dbuserpass' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

> **Notes**
Expand All @@ -154,7 +155,7 @@ A new PostgreSQL database can be created by specifying the `DB_NAME` variable wh
```bash
docker run --name postgresql -itd --restart always \
--env 'DB_NAME=dbname' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

By default databases are created by copying the standard system database named `template1`. You can specify a different template for your database using the `DB_TEMPLATE` parameter. Refer to [Template Databases](http://www.postgresql.org/docs/9.4/static/manage-ag-templatedbs.html) for further information.
Expand All @@ -166,7 +167,7 @@ Additionally, more than one database can be created by specifying a comma separa
```bash
docker run --name postgresql -itd --restart always \
--env 'DB_NAME=dbname1,dbname2' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

## Granting user access to a database
Expand All @@ -177,7 +178,7 @@ If the `DB_USER` and `DB_PASS` variables are specified along with the `DB_NAME`
docker run --name postgresql -itd --restart always \
--env 'DB_USER=dbuser' --env 'DB_PASS=dbuserpass' \
--env 'DB_NAME=dbname1,dbname2' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

In the above example `dbuser` with be granted access to both the `dbname1` and `dbname2` databases.
Expand All @@ -189,7 +190,7 @@ The image also packages the [postgres contrib module](http://www.postgresql.org/
```bash
docker run --name postgresql -itd \
--env 'DB_NAME=db1,db2' --env 'DB_EXTENSION=unaccent,pg_trgm' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

The above command enables the `unaccent` and `pg_trgm` modules on the databases listed in `DB_NAME`, namely `db1` and `db2`.
Expand All @@ -205,7 +206,7 @@ Similar to the creation of a database user, a new PostgreSQL replication user ca
```bash
docker run --name postgresql -itd --restart always \
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

> **Notes**
Expand All @@ -227,7 +228,7 @@ Begin by creating the master node of our cluster:
docker run --name postgresql-master -itd --restart always \
--env 'DB_USER=dbuser' --env 'DB_PASS=dbuserpass' --env 'DB_NAME=dbname' \
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

Notice that no additional arguments are specified while starting the master node of the cluster.
Expand All @@ -242,7 +243,7 @@ docker run --name postgresql-slave01 -itd --restart always \
--env 'REPLICATION_MODE=slave' --env 'REPLICATION_SSLMODE=prefer' \
--env 'REPLICATION_HOST=master' --env 'REPLICATION_PORT=5432' \
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

*In the above command, we used docker links so that we can address the master node using the `master` alias in `REPLICATION_HOST`.*
Expand Down Expand Up @@ -274,7 +275,7 @@ docker run --name postgresql-snapshot -itd --restart always \
--env 'REPLICATION_MODE=snapshot' --env 'REPLICATION_SSLMODE=prefer' \
--env 'REPLICATION_HOST=master' --env 'REPLICATION_PORT=5432' \
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

The difference between a slave and a snapshot is that a slave is read-only and updated whenever the master data is updated (streaming replication), while a snapshot is read-write and is not updated after the initial snapshot of the data from the master.
Expand All @@ -296,7 +297,7 @@ docker run --name postgresql-backup -it --rm \
--env 'REPLICATION_HOST=master' --env 'REPLICATION_PORT=5432' \
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \
--volume /srv/docker/backups/postgresql.$(date +%Y%m%d%H%M%S):/var/lib/postgresql \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

Once the backup is generated, the container will exit and the backup of the master data will be available at `/srv/docker/backups/postgresql.XXXXXXXXXXXX/`. Restoring the backup involves starting a container with the data in `/srv/docker/backups/postgresql.XXXXXXXXXXXX`.
Expand All @@ -307,7 +308,7 @@ You can customize the launch command of PostgreSQL server by specifying argument

```bash
docker run --name postgresql -itd --restart always \
sameersbn/postgresql:15-20230628 -c log_connections=on
sameersbn/postgresql:16-20240429 -c log_connections=on
```

Please refer to the documentation of [postgres](http://www.postgresql.org/docs/9.4/static/app-postgres.html) for the complete list of available options.
Expand All @@ -318,7 +319,7 @@ By default the PostgreSQL server logs are sent to the standard output. Using the

```bash
docker run --name postgresql -itd --restart always \
sameersbn/postgresql:15-20230628 -c logging_collector=on
sameersbn/postgresql:16-20240429 -c logging_collector=on
```

To access the PostgreSQL logs you can use `docker exec`. For example:
Expand All @@ -340,7 +341,7 @@ For example, if you want to assign the `postgres` user of the container the UID
```bash
docker run --name postgresql -itd --restart always \
--env 'USERMAP_UID=999' --env 'USERMAP_GID=999' \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

# Maintenance
Expand All @@ -352,7 +353,7 @@ To upgrade to newer releases:
1. Download the updated Docker image:

```bash
docker pull sameersbn/postgresql:15-20230628
docker pull sameersbn/postgresql:16-20240429
```

2. Stop the currently running image:
Expand All @@ -372,7 +373,7 @@ To upgrade to newer releases:
```bash
docker run --name postgresql -itd \
[OPTIONS] \
sameersbn/postgresql:15-20230628
sameersbn/postgresql:16-20240429
```

## Shell Access
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15-20230628
16-20240429
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PostgreSQL:
restart: always
image: sameersbn/postgresql:15-20230628
image: sameersbn/postgresql:16-20240429
ports:
- "5432:5432"
environment:
Expand Down