mirror of
https://github.com/docker-library/postgres.git
synced 2026-11-20 23:43:23 +03:00
Install a postgresql-common.conf override (#1428)
This avoids the upstream behavior of resetting our carefully crafted "arbitrary user" permissions during the installation of `postgresql-common` -- alternatively, we could set the permissions after the install, but explicitly overriding the package behavior is cleaner. Also, move up the creation of `/run/postgresql` and finally apply the `/var/run` -> `/run` conversion that both Debian and Alpine applied long ago (no longer relying on the compatibility symlink).
This commit is contained in:
1 parent
158600c35f
commit
a4513295fc
43 files changed
+283
-173
No files matched your search
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -107,10 +111,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -192,8 +196,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.24
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -107,10 +111,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -192,8 +196,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -107,10 +111,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -191,8 +195,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.24
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -107,10 +111,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -191,8 +195,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -106,10 +110,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -189,8 +193,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.24
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -106,10 +110,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -189,8 +193,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
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"
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -112,10 +116,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -197,8 +201,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.24
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -112,10 +116,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -197,8 +201,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -183,8 +193,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -183,8 +193,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -112,10 +116,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -197,8 +201,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+9
-7
@@ -6,14 +6,18 @@
|
||||
|
||||
FROM alpine:3.24
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -112,10 +116,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -197,8 +201,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -183,8 +193,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Generated
+11
-3
@@ -11,9 +11,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -183,8 +193,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
#
|
||||
|
||||
Generated
+3
-3
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
-}}
|
||||
FROM alpine:{{ alpine_version }}
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN set -eux; \
|
||||
# 70 is the standard uid/gid for "postgres" in Alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/postgresql-common/postgresql-common.pre-install?h=3.22-stable
|
||||
RUN set -eux; \
|
||||
addgroup -g 70 -S postgres; \
|
||||
adduser -u 70 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql
|
||||
|
||||
# grab gosu for easy step-down from root
|
||||
# https://github.com/tianon/gosu/releases
|
||||
@@ -119,10 +123,10 @@ RUN set -eux; \
|
||||
; \
|
||||
\
|
||||
cd /usr/src/postgresql; \
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/var/run/postgresql" (matching Debian)
|
||||
# update "DEFAULT_PGSOCKET_DIR" to "/run/postgresql" (matching Debian)
|
||||
# see https://anonscm.debian.org/git/pkg-postgresql/postgresql.git/tree/debian/patches/51-default-sockets-in-var.patch?id=8b539fcb3e093a521c095e70bdfa76887217b89f
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/var/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/var/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
awk '$1 == "#define" && $2 == "DEFAULT_PGSOCKET_DIR" && $3 == "\"/tmp\"" { $3 = "\"/run/postgresql\""; print; next } { print }' src/include/pg_config_manual.h > src/include/pg_config_manual.h.new; \
|
||||
grep '/run/postgresql' src/include/pg_config_manual.h.new; \
|
||||
mv src/include/pg_config_manual.h.new src/include/pg_config_manual.h; \
|
||||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
|
||||
\
|
||||
@@ -215,8 +219,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/local/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
{{ if .major >= 18 then ( -}}
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
|
||||
@@ -5,9 +5,19 @@ RUN set -eux; \
|
||||
groupadd -r postgres --gid=999; \
|
||||
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
|
||||
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
|
||||
\
|
||||
# also create the postgres user's home directory with appropriate permissions
|
||||
# see https://github.com/docker-library/postgres/issues/274
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql
|
||||
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
|
||||
\
|
||||
install --verbose --directory --owner postgres --group postgres --mode 3777 /run/postgresql; \
|
||||
\
|
||||
# https://github.com/docker-library/postgres/issues/1427 - override postgresql-common's tmpfiles.d entries
|
||||
mkdir -p /usr/local/lib/tmpfiles.d; \
|
||||
printf '%s\n' \
|
||||
'd /var/lib/postgresql 1777 postgres postgres' \
|
||||
'd /run/postgresql 3777 postgres postgres' \
|
||||
> /usr/local/lib/tmpfiles.d/postgresql-common.conf
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
@@ -179,8 +189,6 @@ RUN set -eux; \
|
||||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample; \
|
||||
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
|
||||
|
||||
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
|
||||
|
||||
{{ if .major >= 18 then ( -}}
|
||||
#
|
||||
# NOTE: in 18+, 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
|
||||
|
||||
@@ -41,8 +41,8 @@ docker_create_db_directories() {
|
||||
chmod 00700 "$PGDATA" || :
|
||||
|
||||
# ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289
|
||||
mkdir -p /var/run/postgresql || :
|
||||
chmod 03775 /var/run/postgresql || :
|
||||
mkdir -p /run/postgresql || :
|
||||
chmod 03775 /run/postgresql || :
|
||||
|
||||
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
|
||||
if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then
|
||||
@@ -56,7 +56,7 @@ docker_create_db_directories() {
|
||||
# allow the container to be started with `--user`
|
||||
if [ "$user" = '0' ]; then
|
||||
find "$PGDATA" \! -user postgres -exec chown postgres '{}' +
|
||||
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
find /run/postgresql \! -user postgres -exec chown postgres '{}' +
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user