Remove intentionally-breaking "data" symlink and add better detection

This allows for a more graceful error message for the case of users who need to update their volume path.

I tested this with 17 and `--env PGDATA=/var/lib/postgresql/17/docker` (to make sure it still works fine and doesn't complain about the extra volume provided by Docker/`VOLUME`) and 18 with `-v /var/lib/postgresql/data` (where it appropriately errors and explains to me what I should be doing instead).

I also did a reflow on some text in the error message that's designed to fit in 80 columns but was taking 81. 😂
This commit is contained in:
Tianon Gravi 2025-10-15 11:16:44 -07:00
parent 06388fc682
commit 5ec8931249
28 changed files with 275 additions and 53 deletions

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -189,7 +189,6 @@ RUN install --verbose --directory --owner postgres --group postgres --mode 3777
# 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
#
ENV PGDATA /var/lib/postgresql/18/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)

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

1
18/trixie/Dockerfile generated
View File

@ -189,7 +189,6 @@ RUN install --verbose --directory --owner postgres --group postgres --mode 3777
# 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
#
ENV PGDATA /var/lib/postgresql/18/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)

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}

View File

@ -190,7 +190,6 @@ RUN install --verbose --directory --owner postgres --group postgres --mode 3777
# 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
#
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 ( -}}

View File

@ -168,8 +168,14 @@ docker_error_old_databases() {
Counter to that, there appears to be PostgreSQL data in:
${OLD_DATABASES[*]}
This is usually the result of upgrading the Docker image without upgrading
the underlying database using "pg_upgrade" (which requires both versions).
This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).
The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.
See https://github.com/docker-library/postgres/issues/37 for a (long)
discussion around this process, and suggestions for how to do so.
@ -264,6 +270,9 @@ docker_setup_env() {
OLD_DATABASES+=( "$d" )
fi
done
if [ "${#OLD_DATABASES[@]}" -eq 0 ] && [ "$PG_MAJOR" -ge 18 ] && mountpoint -q /var/lib/postgresql/data; then
OLD_DATABASES+=( '/var/lib/postgresql/data (unused mount/volume)' )
fi
fi
}