When you get this error it means you've exposed the right port in your Dockerfile, but you have to make sure the app within your container is binding to 0.0.0.0 instead of localhost or 127.0.0.1.

I got this error using Angular CLI's ng serve within a container. I had to add --host=0.0.0.0 to the ENTRYPOINT arguments. If you're using a different framework check for a similar command-line argument, configuration parameter or setting.