FWIW,
For the next step, you might consider changing the proxy to talk to a unix domain socket in the docker container(s).
This setup provides even more flexibility because you can simply do a symbolic link from outside the container to inside and easily switch from one container to another without any downtime and without a need to restart nginx.
For example (on Linux, this will not work on MacOS)
Unix socket might be here (container view), as an example:
/shared/mycool.discourse.sock
Outside container:
ln -sf /var/discourse/shared/socket-only/mycool.discourse.sock /tmp/mycool.discourse.sock
so your external nginx server with reverse proxy to:
/tmp/mycool.discourse.sock
Let’s say you are want add some plugins and need to rebuild.
You can rebuild with /shared/socket-only2 (a simple yml change), and to switch to the new container, just:
ln -sf /var/discourse/shared/socket-only2/mycool.discourse.sock /tmp/mycool.discourse.sock
(or put it in /var/run or wherever …)
This works very smoothly and you can switch back and forth between containers in a few milliseconds, no nginx restart to remap the TCP/IP domain sockets.
I have tested this completely and it works flawlessly and smoothly.
It also works (almost) with Apache2, but in Apache2, you cannot use a symbolic link and must use the full path to the container in the Apache2 site configs, so Apache2 requires a restart to switch, but since you a nginx person, this will be easy and smooth outside the container.