I think @pfaffman means that because your are using a reverse proxy (nginx), the script discourse-setup might not work (I have never run discourse with a reverse proxy, so I don’t know if this is the case). If you define the app.yml correctly it should be fine too, without running discourse-setup.
This seems like it’s trying to execute this code in a container that doesn’t have postgres 10 (you are probably using the version 12). If this is what you want, and your template is templates/postgres.template.yml as defined in your first post, maybe the discourse_docker repository in your machine (at /var/discourse) is outdated.
Is your installed discourse recent or old? It may fix that problem if you update the repository:
cd /var/discourse
git pull
and then run the rebuild step.
Also make sure that the discourse container is destroyed and recreated (and not only stopped and started), to not use an old container (I think the discourse rebuild should already do that, but just in case…).
If it doesn’t work and you have a backup, it is advisable to try to install in a fresh new instance as @Benjamin_D said.