diff --git a/17/alpine3.19/Dockerfile b/17/alpine3.19/Dockerfile index cc263a0644..7e98f9e36e 100644 --- a/17/alpine3.19/Dockerfile +++ b/17/alpine3.19/Dockerfile @@ -194,10 +194,13 @@ RUN set -eux; \ RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql -ENV PGDATA /var/lib/postgresql/data -# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) -RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA" -VOLUME /var/lib/postgresql/data +# +# NOTE: in 17+, PGDATA has changed to match the pg_ctlcluster standard directory structure, and the VOLUME has moved from /var/lib/postgresql/data to /var/lib/postgresql +# +ENV PGDATA /var/lib/postgresql/17/docker +RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494 +VOLUME /var/lib/postgresql +# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above) COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh diff --git a/17/alpine3.20/Dockerfile b/17/alpine3.20/Dockerfile index 07dc7c4750..32fa0b4e16 100644 --- a/17/alpine3.20/Dockerfile +++ b/17/alpine3.20/Dockerfile @@ -194,10 +194,13 @@ RUN set -eux; \ RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql -ENV PGDATA /var/lib/postgresql/data -# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) -RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA" -VOLUME /var/lib/postgresql/data +# +# NOTE: in 17+, PGDATA has changed to match the pg_ctlcluster standard directory structure, and the VOLUME has moved from /var/lib/postgresql/data to /var/lib/postgresql +# +ENV PGDATA /var/lib/postgresql/17/docker +RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494 +VOLUME /var/lib/postgresql +# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above) COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh diff --git a/17/bookworm/Dockerfile b/17/bookworm/Dockerfile index 99dfd4b35c..7567ff3a02 100644 --- a/17/bookworm/Dockerfile +++ b/17/bookworm/Dockerfile @@ -182,10 +182,13 @@ RUN set -eux; \ RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql -ENV PGDATA /var/lib/postgresql/data -# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) -RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA" -VOLUME /var/lib/postgresql/data +# +# NOTE: in 17+, PGDATA has changed to match the pg_ctlcluster standard directory structure, and the VOLUME has moved from /var/lib/postgresql/data to /var/lib/postgresql +# +ENV PGDATA /var/lib/postgresql/17/docker +RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494 +VOLUME /var/lib/postgresql +# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above) COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh diff --git a/17/bullseye/Dockerfile b/17/bullseye/Dockerfile index 249d0cdf80..2a3261b004 100644 --- a/17/bullseye/Dockerfile +++ b/17/bullseye/Dockerfile @@ -182,10 +182,13 @@ RUN set -eux; \ RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql -ENV PGDATA /var/lib/postgresql/data -# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) -RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA" -VOLUME /var/lib/postgresql/data +# +# NOTE: in 17+, PGDATA has changed to match the pg_ctlcluster standard directory structure, and the VOLUME has moved from /var/lib/postgresql/data to /var/lib/postgresql +# +ENV PGDATA /var/lib/postgresql/17/docker +RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494 +VOLUME /var/lib/postgresql +# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above) COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 3d6236e6e8..3f5c6b92de 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -209,10 +209,20 @@ RUN set -eux; \ RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql +{{ if .major >= 17 then ( -}} +# +# NOTE: in 17+, PGDATA has changed to match the pg_ctlcluster standard directory structure, and the VOLUME has moved from /var/lib/postgresql/data to /var/lib/postgresql +# +ENV PGDATA /var/lib/postgresql/{{ .major | tostring }}/docker +RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494 +VOLUME /var/lib/postgresql +# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above) +{{ ) else ( -}} ENV PGDATA /var/lib/postgresql/data # this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA" VOLUME /var/lib/postgresql/data +{{ ) end -}} COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 1fa84903ac..f98190aa28 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -180,10 +180,20 @@ RUN set -eux; \ RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql +{{ if .major >= 17 then ( -}} +# +# NOTE: in 17+, PGDATA has changed to match the pg_ctlcluster standard directory structure, and the VOLUME has moved from /var/lib/postgresql/data to /var/lib/postgresql +# +ENV PGDATA /var/lib/postgresql/{{ .major | tostring }}/docker +RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494 +VOLUME /var/lib/postgresql +# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above) +{{ ) else ( -}} ENV PGDATA /var/lib/postgresql/data # this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA" VOLUME /var/lib/postgresql/data +{{ ) end -}} COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh