Configure Discourse - Environment AWS Linux 2 AMI and Apache2 (httpd)

This is too complicated for me to understand completely, so consider this more of a wild guess than a solution. If the issue is that you’re not getting something to connect to your running docker container via localhost, you might try using the Docker IP. It might also be possible to use the web socket template and use the socket rather than the port. Some argue this is preferable for a number of reasons.

MKJ’s Opinionated Discourse Deployment Configuration might be useful to read.