Files
postgres15replicate/README.md
Bernhard Radermacher 072b7fef92 initial
2026-02-11 12:53:58 +00:00

2.2 KiB

postgres15

Implement automatic primary and standby

Primary

Example compose.yaml for primary instance.

services:
  db:
    image: pendragon.zone/docker/postgres15replicate
    restart: unless-stopped
    shm_size: 128mb
    environment:
      POSTGRES_PASSWORD: ${DB_ROOT_PASSWORD}
      REPLICATOR_PASSWORD: ${REPLICATOR_PASSWORD}
      MAX_CONNECTIONS: "400"

    network_mode: bridge
    ports:
      - 5432:5432

    volumes:
      - data:/var/lib/postgresql/data
      - /docker/postgres_wal:/wal_archive

volumes:
  data:
  • Volume /wal_archive must be mapped to a location available by all replication participants.

  • DB_ROOT_PASSWORD required, must be the same for all replication participants.

  • REPLICATOR_PASSWORD required, must be the same for all replication participants.

  • UPSTREAM must not be set for primary instance.

  • WAL_ARCHIVE default: /wal_archive use different location for write-ahead-logs.

  • TRIGGER_FILE default: i_am_primary, name of the file that promotes a standby instance to primary instance, if it exists in directory /var/lib/postgresql/data.

  • WAL_KEEP_SIZE default: 1GB

  • REPLICATOR_NAME default: replicator name of user for replication.

  • MAX_CONNECTIONS optional, change default value of max_connections configuration value.

Standby

Example compose.yaml for standby instance.

services:
  db:
    image: pendragon.zone/docker/postgres15replicate
    restart: unless-stopped
    shm_size: 128mb
    environment:
      POSTGRES_PASSWORD: ${DB_ROOT_PASSWORD}
      REPLICATOR_PASSWORD: ${REPLICATOR_PASSWORD}
      UPSTREAM: ${UPSTREAM}

    network_mode: bridge
    ports:
      - 5432:5432

    volumes:
      - data:/var/lib/postgresql/data
      - /docker/postgres_wal:/wal_archive

volumes:
  data:
  • Volume /wal_archive must be mapped to a location available by all replication participants.

  • DB_ROOT_PASSWORD required, must be the same for all replication participants.

  • REPLICATOR_PASSWORD required, must be the same for all replication participants.

  • UPSTREAM required, name of the node to replicate from. Can either be primary or a different standby instance.