From 2505e2aaeea70c1c4054a4e13e4cb0f633737491 Mon Sep 17 00:00:00 2001 From: Matt Gallagher Date: Mon, 24 Nov 2025 16:45:09 +0000 Subject: [PATCH] Mount postgres volumes at /var/lib/postgresql This is to resolve errors like the following, now that postgres:latest resolves to the v18 image by default. ```quote 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 https://github.com/docker-library/postgres/pull/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 https://github.com/docker-library/postgres/issues/37 for a (long) discussion around this process, and suggestions for how to do so. ``` --- demos/nodejs-postgres-bucket-storage/docker-compose.yaml | 2 +- services/postgres.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/nodejs-postgres-bucket-storage/docker-compose.yaml b/demos/nodejs-postgres-bucket-storage/docker-compose.yaml index 5218fdc..f0435ba 100644 --- a/demos/nodejs-postgres-bucket-storage/docker-compose.yaml +++ b/demos/nodejs-postgres-bucket-storage/docker-compose.yaml @@ -35,7 +35,7 @@ services: - POSTGRES_PASSWORD=${PG_STORAGE_DATABASE_PASSWORD} - PGPORT=${PG_STORAGE_DATABASE_PORT} volumes: - - pg_storage_data:/var/lib/postgresql/data + - pg_storage_data:/var/lib/postgresql ports: - "${PG_STORAGE_DATABASE_PORT}:${PG_STORAGE_DATABASE_PORT}" healthcheck: diff --git a/services/postgres.yaml b/services/postgres.yaml index e272c0e..8ace49f 100644 --- a/services/postgres.yaml +++ b/services/postgres.yaml @@ -8,7 +8,7 @@ services: - POSTGRES_PASSWORD=${PG_DATABASE_PASSWORD} - PGPORT=${PG_DATABASE_PORT} volumes: - - pg_data:/var/lib/postgresql/data + - pg_data:/var/lib/postgresql ports: - "${PG_DATABASE_PORT}:${PG_DATABASE_PORT}" command: ["postgres", "-c", "wal_level=logical"]