chore(templates): fix postgres volume#15157
Conversation
* 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.
There was a problem hiding this comment.
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/postgresqlfor 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 |
There was a problem hiding this comment.
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.
| - pgdata:/var/lib/postgresql | |
| - pgdata:/var/lib/postgresql/data |
* 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.
|
🚀 This is included in version v3.83.0 |
* 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.
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.