Skip to content

Commit de40cb6

Browse files
committed
deps: update »PostgreSQL« to 18.1
Error: in 18+, these Docker images are configured to store database data in a format which is compatible with "pg_ctlcluster" (specifically, using major-version-specific directory names). This better reflects how PostgreSQL itself works, and how upgrades are to be performed. See also docker-library/postgres#1259 Counter to that, there appears to be PostgreSQL data in: /var/lib/postgresql/data (unused mount/volume) This is usually the result of upgrading the Docker image without upgrading the underlying database using "pg_upgrade" (which requires both versions). The suggested container configuration for 18+ is to place a single mount at /var/lib/postgresql which will then place PostgreSQL data in a subdirectory, allowing usage of "pg_upgrade --link" without mount point boundary issues. See docker-library/postgres#37 for a (long) discussion around this process, and suggestions for how to do so.
1 parent 0792cd0 commit de40cb6

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

README.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,58 @@ Open [http://localhost:5173/?print-pdf](http://localhost:5173/?print-pdf) in a C
2525

2626
## Upgrade PostgreSQL ##
2727

28+
> [!IMPORTANT]
29+
> Error: in 18+, these Docker images are configured to store database data in a
30+
> format which is compatible with "pg_ctlcluster" (specifically, using
31+
> major-version-specific directory names). This better reflects how
32+
> PostgreSQL itself works, and how upgrades are to be performed.
33+
>
34+
> See also docker-library/postgres#1259
35+
>
36+
> Counter to that, there appears to be PostgreSQL data in:
37+
> /var/lib/postgresql/data (unused mount/volume)
38+
>
39+
> This is usually the result of upgrading the Docker image without
40+
> upgrading the underlying database using "pg_upgrade" (which requires both
41+
> versions).
42+
>
43+
> The suggested container configuration for 18+ is to place a single mount
44+
> at /var/lib/postgresql which will then place PostgreSQL data in a
45+
> subdirectory, allowing usage of "pg_upgrade --link" without mount point
46+
> boundary issues.
47+
>
48+
> See docker-library/postgres#37 for a (long)
49+
> discussion around this process, and suggestions for how to do so.
50+
2851
```bash
2952
$ grep 'image: postgres:' compose.yml
30-
image: postgres:16.9
53+
image: postgres:17.7
3154
$ docker compose up postgres -d
32-
[+] Running 2/2
33-
✔ Network vagrant_default Created 0.1s
34-
✔ Container vagrant-postgres-1 Started 0.2s
55+
[+] up 2/2
56+
✔ Network vagrant_default Created 0.1s
57+
✔ Container vagrant-postgres-1 Created 0.0s
3558
$ docker compose exec postgres /usr/bin/pg_dump --username postgres --dbname grafana --blobs > db.out
3659
$ docker compose down postgres
37-
[+] Running 2/2
38-
✔ Container vagrant-postgres-1 Removed 0.1s
39-
✔ Network vagrant_default Removed 0.1s
40-
$ mv ~/postgres ~/postgres-16
60+
[+] down 2/2
61+
✔ Container vagrant-postgres-1 Removed 0.2s
62+
✔ Network vagrant_default Removed 0.2s
63+
$ mv ~/postgres ~/postgres-17
4164
$ mkdir ~/postgres
4265
$ git pull
4366
$ grep 'image: postgres:' compose.yml
44-
image: postgres:17.5
67+
image: postgres:18.1
4568
$ docker compose up postgres -d
46-
[+] Running 1/1
47-
✔ Container vagrant-postgres-1 Started 0.4s
69+
[+] up 2/2
70+
✔ Network vagrant_default Created 0.1s
71+
✔ Container vagrant-postgres-1 Created 0.0s
4872
$ docker compose cp db.out postgres:/db.out
49-
[+] Copying 1/1
50-
✔ vagrant-postgres-1 copy db.out to vagrant-postgres-1:/db.out Copied 0.0s
73+
[+] copy 1/1
74+
✔ vagrant-postgres-1 Copied db.out to vagrant-postgres-1:/db.out 0.1s
5175
$ docker compose exec postgres /usr/bin/psql --username postgres -d grafana -X -f /db.out
52-
docker compose down postgres
53-
[+] Running 2/2
54-
✔ Container vagrant-postgres-1 Removed 0.3s
55-
✔ Network vagrant_default Removed 0.1s
76+
$ docker compose down postgres
77+
[+] down 2/2
78+
✔ Container vagrant-postgres-1 Removed 0.5s
79+
✔ Network vagrant_default Removed 0.1s
5680
```
5781

5882
## Demo

compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ x-common: &labels
66

77
services:
88
postgres:
9-
image: postgres:17.7
9+
image: postgres:18.1
1010
volumes:
11-
- ${POSTGRES_DATA:-postgres_data}:/var/lib/postgresql/data
11+
- ${POSTGRES_DATA:-postgres_data}:/var/lib/postgresql
1212
environment:
1313
POSTGRES_PASSWORD: secret
1414
POSTGRES_DB: grafana

0 commit comments

Comments
 (0)