Docker Community Forums

Share and learn in the Docker community.

IP docker container listens on

I started to learn docker very recently and tried to set up simple “Hello World!” app with Flask. I built container and ran it with ports -p 5000 option and by default Flask running on When I tried to access container from host on it didn’t work (nor localhost:5000, nor Then I changed my flask app to run on and accessed it from host it worked just fine.
So my question is: "Does container only works with with an ip address of and every app I design should only run on that specific ip?
Thank you in advance.

By default, Flask is only accessible from localhost. When you put your app in a container, localhost changes from your host machine (your laptop) to the container. Containers have their own localhosts and your requests are originating from outside the container.

This is analogous to running Flask on your host/laptop and trying to access it from other computers on the wifi network or the public. It would fail similarly.

When you configure Flask to listen to instead of, it will not just listen to requests originating from localhost, but from the outside as well.

Hope this clarified things a bit.