This looks like a PostgreSQL client/server version mismatch.
The backup is being run from the Discourse container, where pg_dump is version 15.15, but the external PostgreSQL server is 18.3:
server version: 18.3; pg_dump version: 15.15
I’d be cautious about modifying the Discourse container unless the Discourse team recommends that. My first instinct would be to keep the external database cluster aligned with the PostgreSQL version Discourse currently expects/supports.