Skip to content
Merged
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
2 changes: 1 addition & 1 deletion 14/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/bfren/alpine-s6:alpine3.20-7.0.2
FROM quay.io/bfren/alpine-s6:alpine3.20-7.0.3

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 15/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/bfren/alpine-s6:alpine3.22-7.0.2
FROM quay.io/bfren/alpine-s6:alpine3.22-7.0.3

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 15/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.19-r0
15.20-r0
2 changes: 1 addition & 1 deletion 15/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.19
15.20
2 changes: 1 addition & 1 deletion 16/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/bfren/alpine-s6:alpine3.24-7.0.2
FROM quay.io/bfren/alpine-s6:alpine3.24-7.0.3

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 16/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15-r0
16.16-r0
2 changes: 1 addition & 1 deletion 16/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15
16.16
2 changes: 1 addition & 1 deletion 17/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/bfren/alpine-s6:alpine3.24-7.0.2
FROM quay.io/bfren/alpine-s6:alpine3.24-7.0.3

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 17/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.11-r0
17.12-r0
2 changes: 1 addition & 1 deletion 17/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.11
17.12
2 changes: 1 addition & 1 deletion 18/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/bfren/alpine-s6:alpine3.24-7.0.2
FROM quay.io/bfren/alpine-s6:alpine3.24-7.0.3

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 18/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.6-r0
18.7-r0
2 changes: 1 addition & 1 deletion 18/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.6
18.7
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [6.0.3] - 2026-11-25

### Changed

- Base image updated to `bfren/alpine-s6` 7.0.3, which rebuilds BusyBox, figlet and Nushell without changing
their versions - see the [Alpine + S6 changelog](https://github.com/bfren/docker-alpine-s6/blob/main/CHANGELOG.md).
- PostgreSQL updated to 15.20, 16.16, 17.12 and 18.7.

### Fixed

- README: said your changes to `postgresql.conf` and `pg_hba.conf` are always kept - a restore writes them again, so
copy them first.
- README: changing the password and moving a database between containers are now lists of steps, and the helper commands
table shows how to run each command.
- `docker-compose.yml` now matches the README Quickstart - it used PostgreSQL 16 and no password.

## [6.0.2] - 2026-11-10

### Changed
Expand Down Expand Up @@ -43,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
that much memory to back up.
- `pg-export dump` is refused - `/backup/dump.sql` would replace the whole cluster on the next start.

[6.0.3]: https://github.com/bfren/docker-postgresql/compare/v6.0.2...v6.0.3
[6.0.2]: https://github.com/bfren/docker-postgresql/compare/v6.0.1...v6.0.2
[6.0.1]: https://github.com/bfren/docker-postgresql/compare/v6.0.0...v6.0.1
[6.0.0]: https://github.com/bfren/docker-postgresql/compare/v5.0.0...v6.0.0
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ services:
- ./v/backup:/backup
```

This example is also in [`docker-compose.yml`](docker-compose.yml).

`.env` (keep it out of version control):

```sh
Expand Down Expand Up @@ -60,16 +62,18 @@ Images are published to Docker Hub (`bfren/postgresql`) and Quay.io (`quay.io/bf
| `postgresqlN` | `postgresql18` | You want the latest image for a PostgreSQL version |
| `postgresqlN-MAJOR` | `postgresql18-6` | You want updates, but not breaking changes |
| `postgresqlN-MINOR` | `postgresql18-6.0` | You want fixes only - **recommended** |
| `postgresqlN-VERSION` | `postgresql18-6.0.2` | You want to pin this image exactly |
| `postgresqlN.M` | `postgresql18.6` | You want an exact PostgreSQL release |
| `postgresqlN.M-VERSION` | `postgresql18.6-6.0.2` | You want to pin both |
| `postgresqlN-VERSION` | `postgresql18-6.0.3` | You want to pin this image exactly |
| `postgresqlN.M` | `postgresql18.7` | You want an exact PostgreSQL release |
| `postgresqlN.M-VERSION` | `postgresql18.7-6.0.3` | You want to pin both |

A new `MAJOR` version means a breaking change. Before moving to one, read the [changelog](CHANGELOG.md), where each breaking change is marked **Breaking**.

| PostgreSQL | Release | Alpine | Supported until |
| ---------- | ------- | ------ | --------------- |
| 18 | 18.6 | 3.24 | November 2030 |
| 17 | 17.11 | 3.24 | November 2029 |
| 16 | 16.15 | 3.24 | November 2028 |
| 15 | 15.19 | 3.22 | November 2027 |
| 18 | 18.7 | 3.24 | November 2030 |
| 17 | 17.12 | 3.24 | November 2029 |
| 16 | 16.16 | 3.24 | November 2028 |
| 15 | 15.20 | 3.22 | November 2027 |
| 14 | 14.17 | 3.20 | November 2026 |

PostgreSQL supports each major version for five years - see the [versioning policy](https://www.postgresql.org/support/versioning/). Older versions still work, but get no more fixes: use them only to get existing data out.
Expand Down Expand Up @@ -127,7 +131,7 @@ This only happens once. Changing the variables later does **not** change the pas
* Inside the container, any user can connect without a password (`trust`) - this is how the helper commands work.
* From other containers and machines, users need a password (`scram-sha-256`), over IPv4 or IPv6.

To change these rules or tune PostgreSQL (e.g. `shared_buffers`), edit `/data/postgresql.conf` or `/data/pg_hba.conf` and restart the container. They are only generated when a cluster is created, so your changes are kept. The server time zone is set to `GB`.
To change these rules or tune PostgreSQL (e.g. `shared_buffers`), edit `/data/postgresql.conf` or `/data/pg_hba.conf` and restart the container. They are only generated when a cluster is created, so your changes are kept across restarts - but a [restore](#restore) creates a new cluster and writes them again, so copy your changes somewhere first and put them back afterwards. The server time zone is set to `GB`.

### Backups

Expand All @@ -151,7 +155,11 @@ You can also restore while the container is stopped: put `dump.sql` or `dump.sql
* `pg-export <database>` saves `/backup/<database>.sql` - except for a database called `dump`, because `/backup/dump.sql` is restored over the whole cluster on the next start.
* `pg-import <database>` runs `/backup/<database>.sql` in that database, creating it (owned by the application user) if it doesn't exist. Files from `pg-export` and the per-database backup files drop and recreate the tables they contain.

To move a database between containers, `pg-export` in one, copy the file to the other's `/backup`, then `pg-import`.
To move a database between containers:

1. In the old container, run `pg-export <database>`.
2. Copy `/backup/<database>.sql` into the new container's `/backup` volume.
3. In the new container, run `pg-import <database>`.

### Version check

Expand All @@ -166,15 +174,15 @@ To upgrade to a newer major version, move the data across in a dump:

### Helper commands

Run these with `docker exec <container> <command>`.
Run these with `docker exec <container> <command>`, e.g. `docker exec db pg-dump`. Interactive commands need `-it`: `docker exec -it db pg psql`.

| Command | Arguments | Description |
| ------------ | --------- | ------------------------------------------------------------------------- |
| `pg` | command | Run a command as `postgres`, e.g. `pg psql` (add `-it` to `docker exec`). |
| `pg-dump` | | Back up now. |
| `pg-restore` | folder | Replace the cluster with a backup folder's dump. |
| `pg-export` | database | Save a database to `/backup/<database>.sql`. |
| `pg-import` | database | Run `/backup/<database>.sql`, creating the database if needed. |
| Command | Description |
| ---------------------- | --------------------------------------------------------------------------- |
| `pg <command>` | Run a command as `postgres`, e.g. `pg psql`. |
| `pg-dump` | Back up now. |
| `pg-restore <folder>` | Replace the whole cluster with a backup folder's dump, e.g. `202610171608`. |
| `pg-export <database>` | Save a database to `/backup/<database>.sql`. |
| `pg-import <database>` | Run `/backup/<database>.sql`, creating the database if needed. |

### Health check

Expand Down Expand Up @@ -203,7 +211,10 @@ Check `docker logs <container>`:

### I changed the password but can't log in

The password is only set on [first start](#first-start). Change it with `docker exec -it <container> pg psql -c "ALTER USER myapp PASSWORD 'new';"`, then update `BF_PG_PASSWORD` to match.
The password is only set on [first start](#first-start), so changing the variable alone does nothing. To change it:

1. Run `docker exec <container> pg psql -c "ALTER USER myapp PASSWORD 'new-password';"`. Inside the container no password is needed, so this works whatever the old one was.
2. Update `BF_PG_PASSWORD` to match, so it is right if you ever start again with an empty `/data`.

### Another container can't connect

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.2
6.0.3
21 changes: 6 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
services:
pgsql:
image: bfren/postgresql:postgresql16
container_name: pgsql
db:
image: quay.io/bfren/postgresql:postgresql18-6.0
restart: unless-stopped
environment:
- BF_PG_BACKUP_COMPRESS_FILES=1
- BF_PG_BACKUP_KEEP_FOR=56day
- BF_PG_APPLICATION=test
- BF_PG_APPLICATION=myapp
- BF_PG_PASSWORD=${DB_PASSWORD}
volumes:
- ./v/db:/data
- ./v/db-backup:/backup
networks:
- pgsql

networks:
pgsql:
driver: bridge
name: pgsql
- ./v/data:/data
- ./v/backup:/backup
2 changes: 1 addition & 1 deletion generate-dockerfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

docker pull bfren/alpine

BASE_VERSION="7.0.2"
BASE_VERSION="7.0.3"
echo "Base: ${BASE_VERSION}"

POSTGRESQL_VERSIONS="14 15 16 17 18"
Expand Down