this is not postgres' fault.
once the latest pgautoupgrade is available, you can do it with this:
docker run --rm \ -v YOUR_DATA_VOLUME:/var/lib/postgresql/data \ -e POSTGRES_USER=USER \ -e POSTGRES_PASSWORD=PW \ -e POSTGRES_DB=DB \ -e PGAUTO_ONESHOT=yes \ pgautoupgrade/pgautoupgrade:18-bookworm