运行我的运行了python应用程序的python脚本的docker run命令后,我在日志中看到了这一点:
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>
当我点击http://127.0.0.1:5000/metrics
时,我看到的页面是烧瓶页面,但是当我点击http://localhost:5000/metrics
时却没有。从概念上讲,这是怎么回事?我以为他们会一样吗?
这是我运行的docker命令:
docker run -e ENV='dev' -e token=foo:bar <application>
我什至没有使用-p
标志,这是怎么回事?我有点迷路了。我如何在没有端口转发的情况下访问docker flask URL?
我的代码是这样的:
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()