[BUG] Postgres Docker Compose incompatible with Postgres 18+ due to data directory change

Author: MikMik1011Created Dec 14, 2025Updated Dec 26, 2025

What is the problem?

The provided Docker Compose configuration for Postgres is incompatible with Postgres 18 and newer. The issue occurs because Postgres 18 changed the default data directory inside the official Docker image. Previously, the data directory was located at /var/lib/postgresql/data, but starting with Postgres 18 it is now /var/lib/postgresql/.

Operating System

Linux

Architecture Version (x86, x64, arm, etc)

x64

Steps to reproduce

  1. Create or use the provided docker-compose.yml with the Postgres service
  2. Start the containers
  3. Observe that the Postgres container keeps restarting and fails to start

Relevant log output

bash