Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Docker Compose fails to start with PostgreSQL 18: PGDATA incompatibility #4717

@abhishekblue

Description

@abhishekblue

Description

docker compose up fails when trying to start PostgreSQL. The container exits with an error about data directory format incompatibility.

Steps to Reproduce

  1. Run docker compose build
  2. Run docker compose up
  3. Watch postgres-db container fail

Error Message

Image

Root Cause

The docker-compose.yml specifies image: postgres with no version tag. Docker pulls the latest PostgreSQL (currently 18). PostgreSQL 18 changed the expected data directory path from /var/lib/postgresql/data to /var/lib/postgresql, causing a mismatch.

Solution

Either:

  1. Pin PostgreSQL to 16: image: postgres:16
  2. Update the volume mount path to match PostgreSQL 18 expectations: /var/lib/postgresql

I can submit a PR with the fix if you decide which approach is preferred.

Environment

  • Docker version: 28.3.3
  • Docker Compose: v2

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions