Skip to content

Docker: upgrade from Postges 11/12 to a newer version #18085

@net47

Description

@net47

Description

Since Postgres 11/12 is now deprecated, is there an official guide how to upgrade to a new Postgres version using Docker? Just changing the base image throws an error:

  db:
    image: docker.io/postgres:15-alpine
    container_name: synapse-db
    environment:
      - POSTGRES_DB=synapse
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=VerySecurePassword
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    volumes:
      - db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 5s
      timeout: 5s
      retries: 10
# docker logs synapse-db

PostgreSQL Database directory appears to contain a database; Skipping initialization

2025-01-15 07:09:06.003 UTC [1] FATAL:  database files are incompatible with server
2025-01-15 07:09:06.003 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.10.

Steps to reproduce

  • change the image tag from docker.io/postgres:12-alpine to docker.io/postgres:15-alpine

Homeserver

self-hosted homeserver

Synapse Version

{"server_version":"1.121.1"}

Installation Method

Docker (matrixdotorg/synapse)

Database

Postgres, single server, not ported but running Postgres from the beginning, no backup restored

Workers

Single process

Platform

Docker on Debian 12

Configuration

no unusual configuration, just using this homeserver.yaml:

...
database:
  name: psycopg2
  args:
    user: synapse
    password: VerySecurePassword
    dbname: synapse
    host: db
    cp_min: 5
    cp_max: 10
user_directory:
    enabled: true
    search_all_users: true
...

Relevant log output

PostgreSQL Database directory appears to contain a database; Skipping initialization

2025-01-15 07:09:06.003 UTC [1] FATAL:  database files are incompatible with server
2025-01-15 07:09:06.003 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.10.

Anything else that would be useful to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions