Skip to content

Volume bind mount path changed with postgres v18 #154

@tobi-dub

Description

@tobi-dub

When setting up a complete new pgbackweb stack with your provided compose example, I get the following error:

$ docker compose up 
[+] Running 3/3
 ✔ Network pgbackweb_default  Created                                                                                                                                          0.1s 
 ✔ Container postgres         Created                                                                                                                                          0.1s 
 ✔ Container pgbackweb        Created                                                                                                                                          0.0s 
Attaching to pgbackweb, postgres
postgres  | Error: in 18+, these Docker images are configured to store database data in a
postgres  |        format which is compatible with "pg_ctlcluster" (specifically, using
postgres  |        major-version-specific directory names).  This better reflects how
postgres  |        PostgreSQL itself works, and how upgrades are to be performed.
postgres  | 
postgres  |        See also https://github.com/docker-library/postgres/pull/1259
postgres  | 
postgres  |        Counter to that, there appears to be PostgreSQL data in:
postgres  |          /var/lib/postgresql/data (unused mount/volume)
postgres  | 
postgres  |        This is usually the result of upgrading the Docker image without
postgres  |        upgrading the underlying database using "pg_upgrade" (which requires both
postgres  |        versions).
postgres  | 
postgres  |        The suggested container configuration for 18+ is to place a single mount
postgres  |        at /var/lib/postgresql which will then place PostgreSQL data in a
postgres  |        subdirectory, allowing usage of "pg_upgrade --link" without mount point
postgres  |        boundary issues.
postgres  | 
postgres  |        See https://github.com/docker-library/postgres/issues/37 for a (long)
postgres  |        discussion around this process, and suggestions for how to do so.
postgres exited with code 1
dependency failed to start: container postgres exited (1)

In your example compose file with postgres v18, the volume bind mount path in the container is wrong. With postgres v18, it changed from /var/lib/postgresql/data to /var/lib/postgresql.

After changing it, the database starts successfully.

$ docker compose up
[...]
pgbackweb-db  | 2025-11-14 20:54:42.081 UTC [1] LOG:  database system is ready to accept connections

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions