Mapping a docker container to specific IP

I am running a minimal flask app on a docker container. I am using
port = int(os.environ.get(‘PORT’, 80))
app.run(debug=True, host=‘0.0.0.0’, port=port)
In order for the webapp to be accessible from my ip address. But I can’t access it from my ip address using :80.
Also, inspecting the container I see it is * Running on http://172.17.0.2:80/ which corresponds to docker.

Hi

Did you map port 80 into the container?

Also, in my a big Flask guy, but i would expect it to be running on “0.0.0.0” as you defined

Hi! Thanks for your reply. Yeah exactly, so it runs perfect on 0.0.0.0:80 and localhost:80. And I use: docker run -p 80:80 -d image_name in order to run the container. But I can’t access it on my ip using :80, I have firewall off.

When you say “my ip” what is it then?

what happends if your application listens on 0.0.0.0 and you try, from your mac, and curl http://localhost
?

Yeah so both 0.0.0.0 and http://localhost work. but when I try accessing it from my IP address in the format 123.123.12.123, I try to paste it in the browser and add the port, so 123.123.12.123:80 I can’t access it. I have also tried to run it on a VM but I had the same issue. Not sure why :confused:

Just for fun, can you try a port different from 80, like “-p 8080:80” ?

I tried it and it has the same outcome, I can access the webapp on 0.0.0.0 and http://localhost but not from my IP