I’m not certain, but I think the problem is probably that discourse is running inside a docker container, and so can’t by default access your separate postgres container.
I think you need to expose the databse using this kind of configuration GitHub - discourse/discourse_docker: A Docker image for Discourse
You may also need to remove the postgres template from the app.yml file.
These docs might be helpful - whilst you’re not running on a separate server everything else should be relevant.
Hope this helps!