Yes thank you, I have tried specifying the port at the CLI too... that did not help.
But restarting PostgreSQL in my custom /docker-entrypoint-initdb.d/run-after-initdb.sh
has helped, even though I am not sure if it is the best way:
#!/bin/sh
LANGUAGES="de en fr nl pl ru"
createuser --username=postgres words
psql --username=postgres -c "GRANT USAGE ON SCHEMA public TO words;"
psql --username=postgres -c "ALTER USER words PASSWORD 'mypassword';"
for L in $LANGUAGES; do
createdb --username=postgres --owner=words words_$L
cd /dict/$L && psql words_$L < words_$L.sql
done
# Restart PostgreSQL to make it listen at localhost too
pg_ctl --options "-c listen_addresses='localhost'" --wait restart