Skip to content

chore(templates): fix postgres volume#15157

Merged
paulpopus merged 1 commit intopayloadcms:mainfrom
dsm23:chore/postgres-template-docker-volume
Apr 13, 2026
Merged

chore(templates): fix postgres volume#15157
paulpopus merged 1 commit intopayloadcms:mainfrom
dsm23:chore/postgres-template-docker-volume

Conversation

@dsm23
Copy link
Copy Markdown
Contributor

@dsm23 dsm23 commented Jan 9, 2026

  • from the docker hub readme:

Important Note: (for PostgreSQL 17 and below) Mount the data volume at /var/lib/postgresql/data and not at /var/lib/postgresql because mounts at the latter path WILL NOT PERSIST database data when the container is re-created. The Dockerfile that builds the image declares a volume at /var/lib/postgresql/data and if no data volume is mounted at that path then the container runtime will automatically create an anonymous volume that is not reused across container re-creations. Data will be written to the anonymous volume rather than your intended data volume and won't persist when the container is deleted and re-created.

What?

Fixes database volume in docker compose for the postgres template.

Why?

The latest major version of docker postgres is now v18.

* from the docker hub readme:

Important Note: (for PostgreSQL 17 and below) Mount the data volume at /var/lib/postgresql/data and not at /var/lib/postgresql because mounts at the latter path WILL NOT PERSIST database data when the container is re-created. The Dockerfile that builds the image declares a volume at /var/lib/postgresql/data and if no data volume is mounted at that path then the container runtime will automatically create an anonymous volume that is not reused across container re-creations. Data will be written to the anonymous volume rather than your intended data volume and won't persist when the container is deleted and re-created.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the PostgreSQL volume mount path in the docker-compose configuration to align with Docker Hub's latest requirements for PostgreSQL 18. The volume mount is changed from /var/lib/postgresql/data to /var/lib/postgresql to ensure database data persistence when containers are recreated.

Changes:

  • Updated PostgreSQL volume mount path to /var/lib/postgresql for compatibility with PostgreSQL 18

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

image: postgres:latest
volumes:
- pgdata:/var/lib/postgresql/data
- pgdata:/var/lib/postgresql
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the Docker Hub documentation cited in the PR description, mounting at /var/lib/postgresql/data is required for PostgreSQL 17 and below to persist data. The change to /var/lib/postgresql contradicts this requirement. While PostgreSQL 18 may have changed this behavior, using postgres:latest (line 22) means the template could pull PostgreSQL 17 or earlier on existing systems, potentially causing data loss. Either pin to a specific PostgreSQL 18+ version or revert this change until PostgreSQL 18 is more widely adopted.

Suggested change
- pgdata:/var/lib/postgresql
- pgdata:/var/lib/postgresql/data

Copilot uses AI. Check for mistakes.
@paulpopus paulpopus merged commit b44135e into payloadcms:main Apr 13, 2026
23 checks passed
Raghvendra2420 pushed a commit to Raghvendra2420/payload that referenced this pull request Apr 13, 2026
* from the docker hub readme:

Important Note: (for PostgreSQL 17 and below) Mount the data volume at
/var/lib/postgresql/data and not at /var/lib/postgresql because mounts
at the latter path WILL NOT PERSIST database data when the container is
re-created. The Dockerfile that builds the image declares a volume at
/var/lib/postgresql/data and if no data volume is mounted at that path
then the container runtime will automatically create an anonymous volume
that is not reused across container re-creations. Data will be written
to the anonymous volume rather than your intended data volume and won't
persist when the container is deleted and re-created.

### What?

Fixes database volume in docker compose for the postgres template.

### Why?

The latest major version of docker postgres is now v18.
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.83.0

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
* from the docker hub readme:

Important Note: (for PostgreSQL 17 and below) Mount the data volume at
/var/lib/postgresql/data and not at /var/lib/postgresql because mounts
at the latter path WILL NOT PERSIST database data when the container is
re-created. The Dockerfile that builds the image declares a volume at
/var/lib/postgresql/data and if no data volume is mounted at that path
then the container runtime will automatically create an anonymous volume
that is not reused across container re-creations. Data will be written
to the anonymous volume rather than your intended data volume and won't
persist when the container is deleted and re-created.

### What?

Fixes database volume in docker compose for the postgres template.

### Why?

The latest major version of docker postgres is now v18.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants