0

After running my docker run command that runs my python script which kicks off a flask app, I see this in my logs:

 2019-08-02 18:29:27,519 - <some_file - INFO - Opening connection for subscription [account]
 * Serving Flask app "webserver.app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
2019-08-02 18:29:27,520 - sources.passport.listener - INFO - Opening connection for subscription [lead]
2019-08-02 18:29:27,523 - sources.passport.listener - INFO - Opening connection for subscription [opportunity]
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 ...<more logs>

When I hit http://127.0.0.1:5000/metrics I see my page which is a flask page but when i hit http://localhost:5000/metrics I do not. Conceptually, what is going on? I thought they would be the same?

This is the docker command that I ran:

docker run -e ENV='dev' -e token=foo:bar <application>

and I'm not even using the -p flag so what is going on? I'm a bit lost. How am I access the docker flask url without port forwarding?

My code is this:

def start_server():
    app.debug = False
    app.run()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()

    threading.Thread(target=start_server).start()

    for subscription in SUBSCRIPTION_TYPES:
        loop.create_task(subscribe(subscription))
    loop.run_forever()
Jwan622
  • 11,015
  • 21
  • 88
  • 181
  • 2
    Possible duplicate of [Deploying a minimal flask app in docker - server connection issues](https://stackoverflow.com/questions/30323224/deploying-a-minimal-flask-app-in-docker-server-connection-issues) – David Maze Aug 02 '19 at 18:36
  • I don't think it's the same question. Mine is accessible – Jwan622 Aug 02 '19 at 18:48
  • 3
    I bet you have some other container or host process listening on that port. In between the missing `-p` option and the Flask process being bound to 127.0.0.1, it shouldn't be possible to reach the containerized Flask app at all. – David Maze Aug 02 '19 at 19:18
  • Possible duplicate of https://stackoverflow.com/questions/55691206/deploying-flask-app-in-docker-unable-to-connect-to-the-site ? – akazuko Aug 02 '19 at 20:13
  • could you share us your docker run command and python script? – JRichardsz Aug 03 '19 at 02:48

0 Answers0