Skip to content

Commit da2ee94

Browse files
committed
PG-2165 ARM64 Docker images have incorrect /data/db ownership causing permission errors
1 parent 50cf956 commit da2ee94

File tree

7 files changed

+98
-42
lines changed

7 files changed

+98
-42
lines changed

percona-distribution-postgresql-13/Dockerfile.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ RUN set -ex; \
6262
microdnf -y reinstall tzdata; \
6363
microdnf clean all
6464

65-
# the numeric UID is needed for OpenShift
66-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
67-
-c "Default Application User" postgres
68-
6965
ENV PGDATA /data/db
66+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
67+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
7068

7169
COPY --from=downloader /downloaded-packages.tar.gz .
7270
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -90,7 +88,7 @@ RUN set -ex; \
9088
percona-wal2json${PPG_MAJOR_VERSION}; \
9189
microdnf clean all; \
9290
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
93-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
91+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
9492

9593
RUN set -ex; \
9694
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/pgsql-${PPG_MAJOR_VERSION}/share/postgresql.conf.sample; \
@@ -116,10 +114,20 @@ COPY entrypoint.sh /entrypoint.sh
116114

117115
VOLUME ["/data/db"]
118116

117+
RUN rm -f /etc/pgbackrest.conf
118+
119+
# add volumes to allow override of pg_hba.conf and postgresql.conf
120+
# add volumes to offer a restore feature
121+
# add volumes to allow storage of postgres WAL segment files
122+
# add volumes for pgbackrest to write to
123+
# The VOLUME directive must appear after all RUN directives to ensure the proper
124+
# volume permissions are applied when building the image
125+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
126+
119127
ENTRYPOINT ["/entrypoint.sh"]
120128

121129
EXPOSE 5432
122130

123-
USER 1001
131+
USER 26
124132

125133
CMD ["postgres"]

percona-distribution-postgresql-14/Dockerfile-postgis.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ RUN set -ex; \
7373
microdnf -y reinstall tzdata; \
7474
microdnf clean all
7575

76-
# the numeric UID is needed for OpenShift
77-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
78-
-c "Default Application User" postgres
79-
8076
ENV PGDATA /data/db
77+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
78+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
8179

8280
COPY --from=downloader /downloaded-packages.tar.gz .
8381
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -109,7 +107,7 @@ RUN set -ex; \
109107
percona-wal2json${PPG_MAJOR_VERSION}; \
110108
microdnf clean all; \
111109
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
112-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
110+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
113111

114112
RUN set -ex; \
115113
export GNUPGHOME="$(mktemp -d)"; \
@@ -156,10 +154,20 @@ COPY entrypoint.sh /entrypoint.sh
156154

157155
VOLUME ["/data/db"]
158156

157+
RUN rm -f /etc/pgbackrest.conf
158+
159+
# add volumes to allow override of pg_hba.conf and postgresql.conf
160+
# add volumes to offer a restore feature
161+
# add volumes to allow storage of postgres WAL segment files
162+
# add volumes for pgbackrest to write to
163+
# The VOLUME directive must appear after all RUN directives to ensure the proper
164+
# volume permissions are applied when building the image
165+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
166+
159167
ENTRYPOINT ["/entrypoint.sh"]
160168

161169
EXPOSE 5432
162170

163-
USER 1001
171+
USER 26
164172

165173
CMD ["postgres"]

percona-distribution-postgresql-14/Dockerfile.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ RUN set -ex; \
6262
microdnf -y reinstall tzdata; \
6363
microdnf clean all
6464

65-
# the numeric UID is needed for OpenShift
66-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
67-
-c "Default Application User" postgres
68-
6965
ENV PGDATA /data/db
66+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
67+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
7068

7169
COPY --from=downloader /downloaded-packages.tar.gz .
7270
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -94,7 +92,7 @@ RUN set -ex; \
9492
percona-wal2json${PPG_MAJOR_VERSION}; \
9593
microdnf clean all; \
9694
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
97-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
95+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
9896

9997
RUN set -ex; \
10098
export GNUPGHOME="$(mktemp -d)"; \
@@ -141,10 +139,20 @@ COPY entrypoint.sh /entrypoint.sh
141139

142140
VOLUME ["/data/db"]
143141

142+
RUN rm -f /etc/pgbackrest.conf
143+
144+
# add volumes to allow override of pg_hba.conf and postgresql.conf
145+
# add volumes to offer a restore feature
146+
# add volumes to allow storage of postgres WAL segment files
147+
# add volumes for pgbackrest to write to
148+
# The VOLUME directive must appear after all RUN directives to ensure the proper
149+
# volume permissions are applied when building the image
150+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
151+
144152
ENTRYPOINT ["/entrypoint.sh"]
145153

146154
EXPOSE 5432
147155

148-
USER 1001
156+
USER 26
149157

150158
CMD ["postgres"]

percona-distribution-postgresql-15/Dockerfile-postgis.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ RUN set -ex; \
7373
microdnf -y reinstall tzdata; \
7474
microdnf clean all
7575

76-
# the numeric UID is needed for OpenShift
77-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
78-
-c "Default Application User" postgres
79-
8076
ENV PGDATA /data/db
77+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
78+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
8179

8280
COPY --from=downloader /downloaded-packages.tar.gz .
8381
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -109,7 +107,7 @@ RUN set -ex; \
109107
percona-wal2json${PPG_MAJOR_VERSION}; \
110108
microdnf clean all; \
111109
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
112-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
110+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
113111

114112
RUN set -ex; \
115113
export GNUPGHOME="$(mktemp -d)"; \
@@ -157,10 +155,20 @@ COPY entrypoint.sh /entrypoint.sh
157155

158156
VOLUME ["/data/db"]
159157

158+
RUN rm -f /etc/pgbackrest.conf
159+
160+
# add volumes to allow override of pg_hba.conf and postgresql.conf
161+
# add volumes to offer a restore feature
162+
# add volumes to allow storage of postgres WAL segment files
163+
# add volumes for pgbackrest to write to
164+
# The VOLUME directive must appear after all RUN directives to ensure the proper
165+
# volume permissions are applied when building the image
166+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
167+
160168
ENTRYPOINT ["/entrypoint.sh"]
161169

162170
EXPOSE 5432
163171

164-
USER 1001
172+
USER 26
165173

166174
CMD ["postgres"]

percona-distribution-postgresql-15/Dockerfile.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ RUN set -ex; \
6262
microdnf -y reinstall tzdata; \
6363
microdnf clean all
6464

65-
# the numeric UID is needed for OpenShift
66-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
67-
-c "Default Application User" postgres
68-
6965
ENV PGDATA /data/db
66+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
67+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
7068

7169
COPY --from=downloader /downloaded-packages.tar.gz .
7270
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -94,7 +92,7 @@ RUN set -ex; \
9492
percona-wal2json${PPG_MAJOR_VERSION}; \
9593
microdnf clean all; \
9694
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
97-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
95+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
9896

9997
RUN set -ex; \
10098
export GNUPGHOME="$(mktemp -d)"; \
@@ -141,10 +139,20 @@ COPY entrypoint.sh /entrypoint.sh
141139

142140
VOLUME ["/data/db"]
143141

142+
RUN rm -f /etc/pgbackrest.conf
143+
144+
# add volumes to allow override of pg_hba.conf and postgresql.conf
145+
# add volumes to offer a restore feature
146+
# add volumes to allow storage of postgres WAL segment files
147+
# add volumes for pgbackrest to write to
148+
# The VOLUME directive must appear after all RUN directives to ensure the proper
149+
# volume permissions are applied when building the image
150+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
151+
144152
ENTRYPOINT ["/entrypoint.sh"]
145153

146154
EXPOSE 5432
147155

148-
USER 1001
156+
USER 26
149157

150158
CMD ["postgres"]

percona-distribution-postgresql-16/Dockerfile-postgis.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ RUN set -ex; \
7373
microdnf -y reinstall tzdata; \
7474
microdnf clean all
7575

76-
# the numeric UID is needed for OpenShift
77-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
78-
-c "Default Application User" postgres
79-
8076
ENV PGDATA /data/db
77+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
78+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
8179

8280
COPY --from=downloader /downloaded-packages.tar.gz .
8381
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -109,7 +107,7 @@ RUN set -ex; \
109107
percona-wal2json${PPG_MAJOR_VERSION}; \
110108
microdnf clean all; \
111109
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
112-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
110+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
113111

114112
RUN set -ex; \
115113
export GNUPGHOME="$(mktemp -d)"; \
@@ -157,10 +155,20 @@ COPY entrypoint.sh /entrypoint.sh
157155

158156
VOLUME ["/data/db"]
159157

158+
RUN rm -f /etc/pgbackrest.conf
159+
160+
# add volumes to allow override of pg_hba.conf and postgresql.conf
161+
# add volumes to offer a restore feature
162+
# add volumes to allow storage of postgres WAL segment files
163+
# add volumes for pgbackrest to write to
164+
# The VOLUME directive must appear after all RUN directives to ensure the proper
165+
# volume permissions are applied when building the image
166+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
167+
160168
ENTRYPOINT ["/entrypoint.sh"]
161169

162170
EXPOSE 5432
163171

164-
USER 1001
172+
USER 26
165173

166174
CMD ["postgres"]

percona-distribution-postgresql-16/Dockerfile.aarch64

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ RUN set -ex; \
6262
microdnf -y reinstall tzdata; \
6363
microdnf clean all
6464

65-
# the numeric UID is needed for OpenShift
66-
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
67-
-c "Default Application User" postgres
68-
6965
ENV PGDATA /data/db
66+
ENV PGROOT="/usr/pgsql-${PPG_MAJOR_VERSION}"
67+
ENV PATH="/pgdata:${PGROOT}/bin:${PATH}"
7068

7169
COPY --from=downloader /downloaded-packages.tar.gz .
7270
RUN tar -xvzf downloaded-packages.tar.gz; \
@@ -94,7 +92,7 @@ RUN set -ex; \
9492
percona-wal2json${PPG_MAJOR_VERSION}; \
9593
microdnf clean all; \
9694
rm -rf /var/cache/dnf /var/cache/yum $PGDATA && mkdir -p $PGDATA /docker-entrypoint-initdb.d; \
97-
chown -R 1001:0 $PGDATA docker-entrypoint-initdb.d
95+
chown -R postgres:postgres $PGDATA docker-entrypoint-initdb.d
9896

9997
RUN set -ex; \
10098
export GNUPGHOME="$(mktemp -d)"; \
@@ -142,10 +140,20 @@ COPY entrypoint.sh /entrypoint.sh
142140

143141
VOLUME ["/data/db"]
144142

143+
RUN rm -f /etc/pgbackrest.conf
144+
145+
# add volumes to allow override of pg_hba.conf and postgresql.conf
146+
# add volumes to offer a restore feature
147+
# add volumes to allow storage of postgres WAL segment files
148+
# add volumes for pgbackrest to write to
149+
# The VOLUME directive must appear after all RUN directives to ensure the proper
150+
# volume permissions are applied when building the image
151+
VOLUME ["/sshd", "/pgconf", "/pgdata", "/pgwal", "/backrestrepo"]
152+
145153
ENTRYPOINT ["/entrypoint.sh"]
146154

147155
EXPOSE 5432
148156

149-
USER 1001
157+
USER 26
150158

151159
CMD ["postgres"]

0 commit comments

Comments
 (0)