• PostgreSQL 14 final release

Upgrading to Postgres 18 in Docker without losing the data

PostgreSQL 14 had its final release on November 12, 2026, so projects still on it are moving up, often straight to 18. From 18, the official postgres image keeps its data in /var/lib/postgresql/18/docker instead of /var/lib/postgresql/data.

What breaks

A compose file that still mounts a volume at /var/lib/postgresql/data makes the entrypoint exit before initdb on a first start. If no mount covers the data directory, the data goes to the image's anonymous volume and disappears when the container is recreated.

Floating tags such as latest have pointed at 18 since September 2025, and 18 can't open data written by 17 or older. 18 also turns data checksums on by default, and pg_upgrade stops when the old cluster has them off.

I checked 52 open pull requests in public repos that bump Postgres to 18. 41 of them still mounted /var/lib/postgresql/data.

How to fix it

Pin the major version in the image tag. Mount the volume at /var/lib/postgresql, or point PGDATA inside the mount you already have. Then move the data itself with pg_upgrade or a dump and restore into a new volume, with a backup taken first.

Check a repository for this

Postgres images in compose files, Dockerfiles, Helm and Kubernetes manifests: old data mounts, missing mounts, floating tags and majors past their final release.

Runs in your browser with 2 anonymous GitHub API requests. Example: 3Corners-Labs/OpenPlanner@b43dfb83eb11.

The same rules run offline in atokim4/pg18-upgrade-check (MIT).

Sources

Dates and wording re-read on the official pages on . Vendors move dates; the official page wins.