0

I am struggling for 3 days now and gone through all over the internet but not able to find an workable soultion. I am using docker on windows 10 home edition with virtual box. I have written a sample flask api :

from flask import Flask
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)

class HelloWorld(Resource):
    def get(self):
        return {'hello':'world'}

api.add_resource(HelloWorld,'/')

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')

I am able to create an image and run it successfully on windows 10 using the docker machine ip

$ docker run -it -p 0.0.0.0:5000:5000 flask_docker
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 218-782-187
192.168.99.1 - - [04/Apr/2020 07:54:46] "GET / HTTP/1.1" 200 -

Now i am able to get a response accessing it from the same laptop/machine using :

enter image description here where 192.168.99.100 is the docker-machine ip.

Now my ISSUE is if i try to access from another machine/phone which is using the same WIFI using :

http://192.168.99.100:5000/

It is giving me an error of NOT CONNECTION REFUSED that other users have but connection timeout/192.168.99.100 took too long to respond/This site can't be reached. Please help, what i am missing here.

BlackEagle
  • 143
  • 2
  • 11
  • Please verify once that the firewall is disabled on your docker-machine? Looks like a networking issue. Also, make sure that you are able to ping from both the machines. – Kapil Khandelwal Apr 04 '20 at 08:52
  • @KapilKhandelwal if i do not deploy apis via docker, i am able to access it on both machines successfully, however how to check firewall on docker-machine ? – BlackEagle Apr 04 '20 at 09:35
  • Does the recipe in [How can I make other machines on my network access my Docker containers (using port mapping)?](https://stackoverflow.com/questions/35206177/how-can-i-make-other-machines-on-my-network-access-my-docker-containers-using-p) work for you? It's old, and hints at a Mac setup, but the instruction to tell VirtualBox to further forward the port is the right approach. – David Maze Apr 04 '20 at 11:18
  • @DavidMaze : I am not getting this for windows 10, can you help here. – BlackEagle Apr 04 '20 at 18:13

0 Answers0