{
  "id": 17802266,
  "title": "How to upgrade Postgres in Docker to 18, and be ready for 19: dump and restore or pg_upgrade --link",
  "url": "https://urgent.news/2026/11/02/how-to-upgrade-postgres-in-docker-to-18-and-be-ready-for-19-dump-and",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-02T13:44:24.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/saimulislamdl/how-to-upgrade-postgres-in-docker-to-18-and-be-ready-for-19-dump-and-restore-or-pgupgrade-link-3gff"
  },
  "original_language": "en",
  "account": "The PostgreSQL 18 image moved the data directory (PGDATA) down one level to /var/lib/postgresql/18/docker, and the volume location to /var/lib/postgresql. This change allows pg_upgrade --link to perform a hard link within a single mount. However, a volume mounted at PGDATA itself, as done by Dokploy for version 18, blocks this functionality.\n\nRehearsing a dump and restore on a copy is advised before deciding on a path, timing it for comparison. A dump and restore method involves re-inserting every row and rebuilding indexes, while pg_upgrade --link is faster, taking 12.9 to 14.4 seconds for data sizes between 1.4 and 8.5 GB, based on End Point's 2015 test.\n\nWhen upgrading from a 17 cluster made with default image settings to 18, data checksums are turned on in 18, causing pg_upgrade to refuse the mismatch. The fix for this issue varies depending on the path chosen for the upgrade.\n\nOnce the new server starts, a restored backup can only be accessed using the --link method. The article includes a step-by-step guide on how to check if the upgrade worked, potential errors, and fixes, as well as specific advice for Dokploy users regarding the mount that blocks an in-place upgrade to version 19.",
  "summary": "I moved a Postgres database on Dokploy from 16 to 18 with pg_upgrade . It went fine, with the database down for under a minute, but it stopped twice on the way. First, pg_upgrade stopped at its checks: old cluster does not use data checksums but the new one does . Then 18 started, and my app couldn't connect. Neither stop was bad luck. Both follow from how the 18 tooling works, and both wait in a…",
  "key_points": [
    "PostgreSQL 18 moved data directory down one level to /var/lib/postgresql/18/docker",
    "pgupgrade --link allows hard link within single mount, but blocked by volume mounted at PGDATA",
    "Dump and restore method slower than pgupgrade --link, but compatible with data checksums"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}