Finally got it to work!
I think it was a mixture between a corrupted git and the result of a previous docker upgrade. I resolved it by pruning all docker containers and images:
cd /opt/discourse
./launcher stop app
docker container prune
docker image prune -a
./launcher rebuild app
This resulted/ended with:
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
/usr/lib/postgresql/15/bin/vacuumdb --all --analyze-in-stages
Running this script will delete the old cluster's data files:
./delete_old_cluster.sh
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE
Old 13 database is stored at /shared/postgres_data_old
To complete the upgrade, rebuild again using:
./launcher rebuild app
-------------------------------------------------------------------------------------
By running the rebuild again, it started working fully:
./launcher rebuild app