Docker Compose Unable To Connect To Port

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 inside the docker container which is totally separate to on the host machine. In my case to fix this I just made Flask listen on 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.

One thought on “Docker Compose Unable To Connect To Port”

Leave a Reply

Your email address will not be published. Required fields are marked *