0

I have a tensorflow serving with flask app running inside a docker container. I gave in flask_client.py file to access from outside the container.

if __name__ == "__main__":
    app.run(host= '0.0.0.0')

When i run this flask_client.py file,

python flask_client.py --server=172.17.0.2:9000
Initialization done.
* Running on http://0.0.0.0:5000/ (press CTRL+C to quit)

My Container IPAddress : 172.17.0.2 and its running on the port 9000

My VM IPAddress: 192.168.99.100

and flask is running on http://0.0.0.0:5000/

But i when tried to access from http://192.168.99.100:5000/, it showed enter image description here

But I could ping 192.168.99.100 and 172.17.0.2 from command prompt

C:\Windows\system32>ping 192.168.99.100

Pinging 192.168.99.100 with 32 bytes of data:
Reply from 192.168.99.100: bytes=32 time=5ms TTL=64
Reply from 192.168.99.100: bytes=32 time=4ms TTL=64
Reply from 192.168.99.100: bytes=32 time=4ms TTL=64
Reply from 192.168.99.100: bytes=32 time=4ms TTL=64

Ping statistics for 192.168.99.100:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 5ms, Average = 4ms

C:\Windows\system32>ping 172.17.0.2

Pinging 172.17.0.2 with 32 bytes of data:
Reply from 172.17.0.2: bytes=32 time=4ms TTL=63
Reply from 172.17.0.2: bytes=32 time=4ms TTL=63
Reply from 172.17.0.2: bytes=32 time=4ms TTL=63
Reply from 172.17.0.2: bytes=32 time=4ms TTL=63

Ping statistics for 172.17.0.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 4ms, Average = 4ms

And when i tired to curl inside the docker container it showed something like this

pic

these are the ports and address inside my docker container :

enter image description here

What should do i do now?

PS: my docker ps is showing any ports

enter image description here

dhinar1991
  • 831
  • 5
  • 21
  • 40

1 Answers1

2

You need to map the internal port 5000 of your Flask app to your hosts public port. For example here I'm mapping 192.168.99.100:80 to your containers-ip port 5000.

So if you access in your local browser http://192.168.99.100 you see the content of your container:5000

docker run -d -p 80:5000 your_image

More on Docker run can be found in the documentation.

Thomas Schwärzl
  • 9,518
  • 6
  • 43
  • 69