From 27d891fb3440ee669db56607b67836d3ce321534 Mon Sep 17 00:00:00 2001 From: Rostislav Dugin Date: Thu, 2 Apr 2026 08:26:07 +0300 Subject: [PATCH] FIX (docker): Use -k /tmp for PostgreSQL socket directory to fix lock file permission denied on NAS systems --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 53fb42e..1ed0ca5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -312,8 +312,6 @@ if [ "\$CURRENT_UID" != "\$PUID" ]; then usermod -o -u "\$PUID" postgres fi -chown -R postgres:postgres /var/run/postgresql - # PostgreSQL 17 binary paths PG_BIN="/usr/lib/postgresql/17/bin" @@ -426,7 +424,12 @@ fi # Function to start PostgreSQL and wait for it to be ready start_postgres() { echo "Starting PostgreSQL..." - gosu postgres \$PG_BIN/postgres -D /databasus-data/pgdata -p 5437 & + # -k /tmp: create Unix socket and lock file in /tmp instead of /var/run/postgresql/. + # On NAS systems (e.g. TrueNAS Scale), the ZFS-backed Docker overlay filesystem + # ignores chown/chmod on directories from image layers, so PostgreSQL gets + # "Permission denied" when creating .s.PGSQL.5437.lock in /var/run/postgresql/. + # All internal connections use TCP (-h localhost), so the socket location does not matter. + gosu postgres \$PG_BIN/postgres -D /databasus-data/pgdata -p 5437 -k /tmp & POSTGRES_PID=\$! echo "Waiting for PostgreSQL to be ready..."