docker - 当我运行我的应用程序的“docker run”时,它运行烧瓶。为什么我不能在 localhost 上访问它,但我可以在 127.0.0.1 上访问它?
问题描述
在运行我的 docker run 命令来运行我的启动烧瓶应用程序的 python 脚本后,我在我的日志中看到了这一点:
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()
解决方案
推荐阅读
- yii2 - yii2中通过表名获取模型
- ios - 在连接之前识别 CBPeripheral 的类型
- drools - Drools 工作台 7.5.0.Final 无法向其包白名单添加一些依赖项
- javascript - 过滤器不适用于没有属性的数组
- c - 带有显示“不完整序列”的 recv 缓冲区的 C 指针
- here-api - 以 locationid 作为参数的地理编码不提供特定 locationid 的结果 - 'NT_9i7d-q6Hvc8hOg28FefIuD'
- python - Firefox Python selenium 不会无头
- javascript - jQuery selectric 插件的可访问性
- mysql - 如何将另一个表的 2 列连接到 1 个表?
- windows - 如何取消将 chromedriver 设置为系统变量