Published

PostgreSQL

PostgreSQL is an open-source relational database server. This profile runs one PostgreSQL 18 server from the official Docker image.

Resources by load level

What the app itself needs at each level, next to what we recommend for a server that runs only this app.

LevelWhat it meansApp requirementsRecommended
LightEstimateUp to 5 GB of data and 20 concurrent connections (one small app or a few internal tools).1 vCPU · 1 GiB RAM · 6.5 GiB disk1.32 vCPU · 2.7 GiB RAM · 16.79 GiB disk
MediumEstimateUp to 50 GB of data and 100 concurrent connections (the default max_connections).2 vCPU · 4 GiB RAM · 51.5 GiB disk2.52 vCPU · 6.3 GiB RAM · 68.54 GiB disk
HeavyEstimateUp to 200 GB of data and 200 concurrent connections (several production apps on one server).4 vCPU · 16 GiB RAM · 201.5 GiB disk4.92 vCPU · 20.7 GiB RAM · 241.04 GiB disk

Recommended = app requirements + system baseline + safety headroom, under sizing policy 2026.10.0. Options stay at their defaults. “Estimate” means the sources give no number for that case, so it is worked out from them by the method stated under Components. How the numbers are built

Size it in the Stack Sizer

Need a server for this? Look for at least 1.32 vCPU / 2.7 GiB RAM

Based on the Recommended figure for Light load above, which includes system baseline and safety headroom.

ANAROQ is in development and doesn't sell servers. These are some options for renting a server, in no particular order.

Regular links, not affiliate links. ANAROQ earns nothing from them. Providers are not ranked. How ANAROQ may earn from links

Ready-to-run files

Support level Run-tested

Compose template verified by a run on the current profile version.

Create docker-compose

Components

What each component needs at each load level, before baseline and headroom.

vCPU / GiB RAM / GiB disk
ComponentLightMediumHeavySources
PostgreSQL (database)1 / 1 / 6.52 / 4 / 51.54 / 16 / 201.5[2][3][4][5][6][7][8]
How the estimates are worked out
  • PostgreSQL · Light: No upstream sizing table. RAM: shared_buffers 256 MB = 25% of 1 GiB (docs guidance for dedicated servers with ≥ 1 GB); the other 768 MB covers worst-case 20 connections × work_mem 4 MB × hash_mem_multiplier 2 (160 MB) plus 4 × maintenance_work_mem 64 MB (3 autovacuum workers + 1 session). vCPU: one active backend process (process per connection). Disk: 0.5 GiB image (155 MiB compressed × 3, rounded up) + 5 GiB data + 1 GiB WAL (max_wal_size default); GB taken as GiB.
  • PostgreSQL · Medium: RAM: 4 × light; shared_buffers 1 GiB = 25% (docs guidance); the other 3 GiB covers worst-case 100 connections × work_mem 4 MB × hash_mem_multiplier 2 (800 MB) plus 4 × maintenance_work_mem 64 MB. vCPU: 2 active backend processes, or a leader plus one parallel worker. Disk: 0.5 GiB image (155 MiB compressed × 3, rounded up) + 50 GiB data + 1 GiB WAL (max_wal_size default); GB taken as GiB.
  • PostgreSQL · Heavy: RAM: 4 × medium; shared_buffers 4 GiB = 25% (docs guidance); the other 12 GiB covers worst-case 200 connections × work_mem 4 MB × hash_mem_multiplier 2 (1.6 GB) plus 4 × maintenance_work_mem 64 MB, the rest is OS cache. vCPU: a query leader + 2 parallel workers (max_parallel_workers_per_gather default) + 1 for autovacuum and other sessions. Disk: 0.5 GiB image + 200 GiB data + 1 GiB WAL; GB taken as GiB.

Ports

Public ports are meant to be reached from outside the stack, usually through a reverse proxy; internal ones stay on the stack's own network.

ComponentPortExposurePurposeSources
PostgreSQL5432/tcpInternal onlyPostgreSQL client connections (keep on the internal Docker network)[3][12]

Every port in the catalog, with conflicts between apps

User and permissions (UID/GID)

The user each container's process runs as, and the paths it writes to. A bind mount for one of these paths must be writable by that UID:GID.

ComponentUID:GIDUserStarts as rootWrites toSources
PostgreSQL999:999postgresYes, prepares its directories, then drops to this user/var/lib/postgresql/var/run/postgresql[7][12][17]

Permission denied on a mount? Get the exact check and chown for this app

Storage growth

How much each component's data grows per month at each load level, on top of the disk in the profile. A value marked Assumption is ANAROQ's stated assumption, not a figure from the sources; the notes say what it rests on.

GiB per month
ComponentLightMediumHeavySources
PostgreSQLAssumption0.4174.16716.667
What the growth figures rest on
  • PostgreSQL: Upstream gives no growth rate. ANAROQ assumes the data reaches this preset's 5 GB cap in 12 months (5 / 12, GB taken as GiB). WAL stays bounded by max_wal_size and is not counted.
  • PostgreSQL: Upstream gives no growth rate. ANAROQ assumes the data reaches this preset's 50 GB cap in 12 months (50 / 12, GB taken as GiB). WAL stays bounded by max_wal_size and is not counted.
  • PostgreSQL: Upstream gives no growth rate. ANAROQ assumes the data reaches this preset's 200 GB cap in 12 months (200 / 12, GB taken as GiB). WAL stays bounded by max_wal_size and is not counted.

Upgrade and rollback

How to move to a new version safely, and how to go back if it fails.

Back up first

Before a major upgrade, take a pg_dumpall of the whole cluster (with writes stopped) and keep it off the server; for pg_upgrade --link, also keep a copy of the stopped volume. [13][14][18][19]

Upgrade steps

  1. Minor update (for example 18.6 to 18.7): change the image tag within the same major and recreate the container. The data directory stays unchanged. [18]
  2. Major upgrade: first read the Migration section of the release notes of every major version you cross, and test your apps against the new version. [18]
  3. Major upgrade by dump and restore: run pg_dumpall in the old container, stop it, start the new major image on a new empty volume, and load the dump with psql. [13][18]
  4. Faster major upgrade: pg_upgrade with --link, which needs the old and new binaries side by side. With the volume at /var/lib/postgresql, the version-specific PGDATA (/var/lib/postgresql/<major>/docker) of both versions sits on one volume, so --link works. [7][19]

Roll back

Minor: go back to the previous tag of the same major (minor releases share the storage format). Dump and restore: the old volume is untouched, start the old image on it. pg_upgrade --link: the old cluster is safe only if the new one was never started; otherwise restore from the backup. [18][19]

Known breaking changes

  • In 18.0: initdb now enables data checksums by default, and pg_upgrade requires matching checksum settings (use --no-data-checksums for the new cluster when the old one has none). MD5 password authentication is deprecated: move roles to scram-sha-256. [20]
  • In 18 (Docker image): The official image moved PGDATA to /var/lib/postgresql/18/docker and the VOLUME to /var/lib/postgresql. Mounts and volumes must target /var/lib/postgresql instead of the old /var/lib/postgresql/data. [7][12]

Limits

  • Each connection is a separate backend process, and max_connections (default 100) can only be changed at server start; many short-lived connections need a pooler in front of the server. [3][6]
  • Docker gives containers a 64 MB /dev/shm by default; parallel queries can fail with 'could not resize shared memory segment'. Set shm_size (for example 256MB) in Compose. [7]
  • The image ships default settings (shared_buffers 128 MB, work_mem 4 MB). The figures above assume shared_buffers is raised to 25% of the RAM given, for example with -c shared_buffers=1GB. [2][7]
  • From PostgreSQL 18 the image keeps data in /var/lib/postgresql/18/docker and the volume must be mounted at /var/lib/postgresql; a major upgrade needs pg_upgrade or dump and restore. [7][12]

Security

  • Do not publish port 5432 to the internet. Reach it from other containers on the Docker network, or over a VPN or SSH tunnel. [3][12]
  • Network connections use scram-sha-256 password authentication by default. Never set POSTGRES_HOST_AUTH_METHOD=trust: it lets anyone connect without a password. [3][7][16]
  • POSTGRES_PASSWORD is required and creates a superuser. Pass it as a Docker secret (POSTGRES_PASSWORD_FILE) and give each app its own non-superuser role. [7]

Backup

  • Back up with pg_dump (a consistent logical dump per database) on a schedule, and store the dumps off the server. [13]
  • For point-in-time recovery, take base backups with pg_basebackup and archive the WAL continuously (archive_mode, archive_command). [15]
  • Copying the volume (/var/lib/postgresql) is a valid backup only while the server is stopped, or from an atomic snapshot of the whole volume. [7][14]

Latest release

Newest upstream release
PostgreSQL 18.6 [21][22]
This profile was checked against

PostgreSQL 18.6

This profile was checked against the newest release.

Checked on
13 Oct 2026
State
Checked within the last 90 days
Where releases are published
Project site

Latest releases of every app

Version

Profile status
Published
Checked against release
PostgreSQL 18.6
Profile version
1.1.0
Figures verified
10 Oct 2026
Catalog release
2026.10.10
Sizing policy
2026.10.0
Compose file
Verified on 12 Oct 2026
Official site
www.postgresql.org

Sources

  1. Docker Docs: Control startup order in Compose (pg_isready healthcheck, service_healthy) (Official docs · read 11 Oct 2026)
  2. PostgreSQL 18 documentation: 19.4 Resource Consumption (Official docs · read 10 Oct 2026)
  3. PostgreSQL 18 documentation: 19.3 Connections and Authentication (Official docs · read 10 Oct 2026)
  4. PostgreSQL 18 documentation: 19.10 Vacuuming (autovacuum settings) (Official docs · read 10 Oct 2026)
  5. PostgreSQL 18 documentation: 19.5 Write Ahead Log (max_wal_size) (Official docs · read 10 Oct 2026)
  6. PostgreSQL 18 documentation: 51.2 How Connections Are Established (Official docs · read 10 Oct 2026)
  7. Docker Official Image postgres: documentation (docker-library/docs) (Official docs · read 10 Oct 2026)
  8. Docker Hub: library/postgres tag 18.6 (compressed image sizes) (Official repository · read 10 Oct 2026)
  9. PostgreSQL Versioning Policy (supported versions and current minor releases) (Release notes · read 10 Oct 2026)
  10. PostgreSQL 18.6 release notes (Release notes · read 10 Oct 2026)
  11. docker-library/official-images: library/postgres (tags 18.6, 18, latest) (Official repository · read 10 Oct 2026)
  12. docker-library/postgres: 18/trixie Dockerfile (PGDATA, VOLUME, EXPOSE 5432) (Official repository · read 10 Oct 2026)
  13. PostgreSQL 18 documentation: 25.1 SQL Dump (Official docs · read 10 Oct 2026)
  14. PostgreSQL 18 documentation: 25.2 File System Level Backup (Official docs · read 10 Oct 2026)
  15. PostgreSQL 18 documentation: 25.3 Continuous Archiving and Point-in-Time Recovery (Official docs · read 10 Oct 2026)
  16. PostgreSQL 18 documentation: 20.5 Password Authentication (Official docs · read 10 Oct 2026)
  17. docker-library/postgres: 18/trixie docker-entrypoint.sh (chown PGDATA, then gosu postgres) (Official repository · read 13 Oct 2026)
  18. PostgreSQL 18 documentation: 18.6 Upgrading a PostgreSQL Cluster (minor vs major, pg_dumpall) (Official docs · read 13 Oct 2026)
  19. PostgreSQL 18 documentation: pg_upgrade (including Reverting to old cluster) (Official docs · read 13 Oct 2026)
  20. PostgreSQL 18.0 release notes: Migration to Version 18 (Release notes · read 13 Oct 2026)
  21. PostgreSQL Versioning Policy (current minor of 18 is 18.6; 19 only in beta) (Release notes · read 13 Oct 2026)
  22. docker-library/official-images: library/postgres (18.6 = 18 = latest; 19beta4) (Official repository · read 13 Oct 2026)

All self-hosted apps