I am having the same problem like here and here
I am Trying to run a flask app inside docker container.It works fine with '0.0.0.0' but it throws error with my ip address
I am behind a corporate proxy. When i checked my ip address with ipconfig, it showed IP Address as : 10.***.**.**
And I am using docker toolbox where my container ip is 172.17.0.2 and VM IP Address is 192.168.99.100.
I have a flask app running inside this docker with host
if __name__ == "__main__":
app.run(host= '0.0.0.0')
works fine. But when i change it to my ip address
if __name__ == "__main__":
app.run(host= '10.***.**')
throws error :
socket.error:[errno 99] cannot assign requested address
I checked again the ip address with a simple flask application which is running on local (i.e without docker)
if __name__ == "__main__":
app.run(host= '10.***.**')
It worked fine.
So the problem is coming only when running inside the docker. And that's because i am behind a router running NAT with internal ip address. And how do i find this internal ip address with NAT? I have already done port forwarding for flask application with port 5000.
> iptables -t nat -A DOCKER -p tcp --dport 5000 -j DNAT --to-destination 172.17.0.2:5000
> iptables -t nat -A POSTROUTING -j MASQUERADE -p tcp --source 172.17.0.2 --destination 172.17.0.2 --dport https
> iptables -A DOCKER -j ACCEPT -p tcp --destination 172.17.0.2 --dport https