Skip to content

fix: pin postgres to version 17 to avoid data directory incompatibility - #324

Merged
YOU54F merged 1 commit into
pact-foundation:masterfrom
FRosner:fix/pin-postgres-17
Mar 5, 2026
Merged

fix: pin postgres to version 17 to avoid data directory incompatibility#324
YOU54F merged 1 commit into
pact-foundation:masterfrom
FRosner:fix/pin-postgres-17

Conversation

@FRosner

@FRosner FRosner commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Pins the postgres image to postgres:17 in docker-compose.yml. Postgres 18+ changed the default data directory structure, causing startup failures for users with existing volumes mounted at /var/lib/postgresql/data:

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

After pinning to 17 it works:

postgres-1  | The files belonging to this database system will be owned by user "postgres".
postgres-1  | This user must also own the server process.
postgres-1  |
postgres-1  | The database cluster will be initialized with locale "en_US.utf8".
postgres-1  | The default database encoding has accordingly been set to "UTF8".
postgres-1  | The default text search configuration will be set to "english".
postgres-1  |
postgres-1  | Data page checksums are disabled.
postgres-1  |
postgres-1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres-1  | creating subdirectories ... ok
postgres-1  | selecting dynamic shared memory implementation ... posix
postgres-1  | selecting default "max_connections" ... 100
postgres-1  | selecting default "shared_buffers" ... 128MB
postgres-1  | selecting default time zone ... Etc/UTC
postgres-1  | creating configuration files ... ok
postgres-1  | running bootstrap script ... ok
postgres-1  | performing post-bootstrap initialization ... ok
postgres-1     | initdb: warning: enabling "trust" authentication for local connections
postgres-1     | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
postgres-1     | syncing data to disk ... ok
postgres-1     |
postgres-1     |
postgres-1     | Success. You can now start the database server using:
postgres-1     |
postgres-1     |     pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres-1     |
postgres-1     | waiting for server to start....2026-03-05 14:29:38.814 UTC [48] LOG:  starting PostgreSQL 17.9 (Debian 17.9-1.pgdg13+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
postgres-1     | 2026-03-05 14:29:38.814 UTC [48] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres-1     | 2026-03-05 14:29:38.816 UTC [51] LOG:  database system was shut down at 2026-03-05 14:29:38 UTC
postgres-1     | 2026-03-05 14:29:38.818 UTC [48] LOG:  database system is ready to accept connections
postgres-1     |  done
postgres-1     | server started
postgres-1     |
postgres-1     | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres-1     |
postgres-1     | waiting for server to shut down...2026-03-05 14:29:38.929 UTC [48] LOG:  received fast shutdown request
postgres-1     | .2026-03-05 14:29:38.931 UTC [48] LOG:  aborting any active transactions
postgres-1     | 2026-03-05 14:29:38.931 UTC [48] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
postgres-1     | 2026-03-05 14:29:38.932 UTC [49] LOG:  shutting down
postgres-1     | 2026-03-05 14:29:38.932 UTC [49] LOG:  checkpoint starting: shutdown immediate
postgres-1     | 2026-03-05 14:29:38.934 UTC [49] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.003 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/14ED7C8, redo lsn=0/14ED7C8
postgres-1     | 2026-03-05 14:29:38.935 UTC [48] LOG:  database system is shut down
postgres-1     |  done
postgres-1     | server stopped
postgres-1     |
postgres-1     | PostgreSQL init process complete; ready for start up.
postgres-1     |
postgres-1     | 2026-03-05 14:29:39.047 UTC [1] LOG:  starting PostgreSQL 17.9 (Debian 17.9-1.pgdg13+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
postgres-1     | 2026-03-05 14:29:39.048 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres-1     | 2026-03-05 14:29:39.048 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres-1     | 2026-03-05 14:29:39.049 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres-1     | 2026-03-05 14:29:39.050 UTC [62] LOG:  database system was shut down at 2026-03-05 14:29:38 UTC
postgres-1     | 2026-03-05 14:29:39.052 UTC [1] LOG:  database system is ready to accept connections
postgres-1     | 2026-03-05 14:29:41.981 UTC [66] ERROR:  relation "schema_migrations" does not exist at character 27
postgres-1     | 2026-03-05 14:29:41.981 UTC [66] STATEMENT:  SELECT NULL AS "nil" FROM "schema_migrations" LIMIT 1
postgres-1     | 2026-03-05 14:29:41.983 UTC [66] ERROR:  relation "schema_info" does not exist at character 27
postgres-1     | 2026-03-05 14:29:41.983 UTC [66] STATEMENT:  SELECT NULL AS "nil" FROM "schema_info" LIMIT 1

🤖 Generated with Claude Code

Postgres 18+ changed the default data directory structure, causing
startup failures when using an existing volume mounted at
/var/lib/postgresql/data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@FRosner

FRosner commented Mar 5, 2026

Copy link
Copy Markdown
Contributor Author

@YOU54F can you take a look please? :)

@YOU54F
YOU54F merged commit dd1a22d into pact-foundation:master Mar 5, 2026
@YOU54F

YOU54F commented Mar 5, 2026

Copy link
Copy Markdown
Member

Thanks @FRosner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants