I have recently been writing some code and decided to use Docker Compose for my development environment. My environment consists of Redis, MySQL and a Flask application. Something strange was happening however when trying to connect to the flask application. Chrome on my local machine would never connect, it was almost as if the port was not listening at all. However looking at netstat showed the port was infact listening and a quick docker inspect showed the port mapping. So why could I not connect to my Flask application running within my docker container? Well it turns out to be something stupidly simple, the Flask application was listening on 127.0.0.1 inside the docker container which is totally separate to 127.0.0.1 on the host machine. In my case to fix this I just made Flask listen on 0.0.0.0 and suddenly I am now able to connect.
I hope the above helps someone else out with a similar issue, I had been scratching my head for a while until I realised what the issue was.
You’ve got impressive knowlwdge these.