You shared the connection configuration for a python app, but still nothing Docker related. Let me emphesize it again:
I still see nothing that would indicate any Docker issue. You have a postgres error message. We don’t know your database, we don’t know what it should container what it shouldn’t, how you start the database, using what Docker image, with what parameters. so we don’t know what is possible in your case and what isn’t.
We know only what you share, and the details you shared so far could be totally not related to Docker.