Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc059fba

Browse files
committed
ChangePGDATA in 17+ to/var/lib/postgresql/MAJOR/docker
This is a pretty large breaking change, which is why this only makes the change in 17+ (which is currently in pre-release stages, and not due for GA until September, and pre-release `PGDATA` directories are officially *not supported* on the GA release anyhow).Concretely, this changes `PGDATA` to `/var/lib/postgresql/MAJOR/docker`, which matches the pre-existing convention/standard of the `pg_ctlcluster`/`postgresql-common` set of commands, and frankly is what we should've done to begin with, in a classic case of Chesterton's Fence (https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence).This also changes the `VOLUME` to `/var/lib/postgresql`, which should be more reasonable, and make the upgrade constraints more obvious.For any users who have been testing the pre-releases, the simplest way to keep your existing data directory is going to be to add `PGDATA=/var/lib/postgresql/data` as an environment variable on your container or adjust your bind-mount from `/var/lib/postgresql/data` to `/var/lib/postgresql/17/docker`, but the *best* way is going to be to refactor your host directory such that your data lives at `17/docker` inside and you can then mount directly to `/var/lib/postgresql` (possibly setting `PGDATA=/var/lib/postgresql/MAJOR/docker` as well, if you want to go overboard on being explicit).
1 parent66da384 commitc059fba

File tree

6 files changed

+48
-16
lines changed

6 files changed

+48
-16
lines changed

‎17/alpine3.19/Dockerfile

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎17/alpine3.20/Dockerfile

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎17/bookworm/Dockerfile

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎17/bullseye/Dockerfile

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Dockerfile-alpine.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,20 @@ RUN set -eux; \
209209

210210
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
211211

212+
{{ if .major >= 17 then ( -}}
213+
#
214+
# 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
215+
#
216+
ENV PGDATA /var/lib/postgresql/{{ .major | tostring }}/docker
217+
RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494
218+
VOLUME /var/lib/postgresql
219+
# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above)
220+
{{ ) else ( -}}
212221
ENV PGDATA /var/lib/postgresql/data
213222
# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values)
214223
RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA"
215224
VOLUME /var/lib/postgresql/data
225+
{{ ) end -}}
216226

217227
COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/
218228
RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh

‎Dockerfile-debian.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,20 @@ RUN set -eux; \
180180

181181
RUN install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql
182182

183+
{{ if .major >= 17 then ( -}}
184+
#
185+
# 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
186+
#
187+
ENV PGDATA /var/lib/postgresql/{{ .major | tostring }}/docker
188+
RUN ln -svT . /var/lib/postgresql/data # https://github.com/docker-library/postgres/pull/1259#issuecomment-2215477494
189+
VOLUME /var/lib/postgresql
190+
# ("/var/lib/postgresql" is already pre-created with suitably usable permissions above)
191+
{{ ) else ( -}}
183192
ENV PGDATA /var/lib/postgresql/data
184193
# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values)
185194
RUN install --verbose --directory --owner postgres --group postgres --mode 1777 "$PGDATA"
186195
VOLUME /var/lib/postgresql/data
196+
{{ ) end -}}
187197

188198
COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/
189199
RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp