fix(docker): resolve permission denied error for PG18+ volume mounts
Some checks failed
🚀 Docker Build and Push / build-and-push (15) (push) Failing after 3s
🚀 Docker Build and Push / build-and-push (16) (push) Failing after 2s
🚀 Docker Build and Push / build-and-push (17) (push) Failing after 3s
🚀 Docker Build and Push / build-and-push (18) (push) Failing after 3s

PostgreSQL 18+ Docker images changed the data directory structure to use
versioned subdirectories (e.g., /var/lib/postgresql/18/main) instead of
the traditional /var/lib/postgresql/data path.

Changes:
- Dockerfile: Add mkdir and chown to ensure /var/lib/postgresql has
  correct permissions for the postgres user before volume mount
- README.md: Update Quick Start with volume mount example
- README.md: Add 'Data Persistence' section explaining PG18+ requirements

This fixes the 'mkdir: cannot create directory: Permission denied' error
that occurred when mounting volumes at /var/lib/postgresql.

See: https://github.com/docker-library/postgres/pull/1259
This commit is contained in:
2025-12-25 16:46:34 +01:00
parent df585b765a
commit 059048b4ab
2 changed files with 10 additions and 0 deletions

View File

@@ -46,6 +46,9 @@ COPY --from=builder /tmp/timescaledb/usr/share/postgresql/ /usr/share/postgresql
COPY init-extensions.sh /docker-entrypoint-initdb.d/
RUN chmod +x /docker-entrypoint-initdb.d/init-extensions.sh
# Ensure correct permissions for data directory (important for PG18+ with volume mounts)
RUN mkdir -p /var/lib/postgresql && chown -R postgres:postgres /var/lib/postgresql
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD pg_isready -U postgres || exit 1