fix(docker): resolve permission denied error for PG18+ volume mounts
All checks were successful
🚀 Docker Build and Push / build-and-push (15) (push) Successful in 4m44s
🚀 Docker Build and Push / build-and-push (16) (push) Successful in 4m48s
🚀 Docker Build and Push / build-and-push (17) (push) Successful in 4m47s
🚀 Docker Build and Push / build-and-push (18) (push) Successful in 4m36s
All checks were successful
🚀 Docker Build and Push / build-and-push (15) (push) Successful in 4m44s
🚀 Docker Build and Push / build-and-push (16) (push) Successful in 4m48s
🚀 Docker Build and Push / build-and-push (17) (push) Successful in 4m47s
🚀 Docker Build and Push / build-and-push (18) (push) Successful in 4m36s
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:
14
docker-entrypoint-wrapper.sh
Normal file
14
docker-entrypoint-wrapper.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Fix permissions for mounted volumes (PG18+ requirement)
|
||||
# This runs as root before switching to postgres user
|
||||
if [ "$(id -u)" = '0' ]; then
|
||||
# Ensure data directory exists with correct permissions
|
||||
mkdir -p /var/lib/postgresql
|
||||
chown -R postgres:postgres /var/lib/postgresql
|
||||
chmod 700 /var/lib/postgresql
|
||||
fi
|
||||
|
||||
# Execute the original entrypoint
|
||||
exec docker-entrypoint.sh "$@"
|
||||
Reference in New Issue
Block a user