【发布时间】:2018-01-16 09:42:09
【问题描述】:
问题:
来自 Windows 主机。端口映射/暴露不起作用。
容器应用不可访问。
curl http://localhost:PORT (127.0.0.1 / 0.0.0.0)
-> Could not get any response
curl http://DOCKER-IP:PORT (127.17.0.1 / 127.17.0.2)
-> Could not get any response
curl http://DOCKER-SUBNET-ADDRESS:PORT (10.0.75.0)
-> Could not get any response
设置:
Windows10主机系统 + Docker 容器(带有简单的 helloworld python flask app)
Docker 容器正在运行。 在 docker 容器内,flask 应用程序的行为与预期相同。
复制:
-
获取 hello world 代码库
git clone https://github.com/shekhargulati/python-flask-docker-hello-world -
构建并运行 docker 容器
docker build -t simple-flask-app:latest . docker run -d -p 5000:5000 simple-flask-app --name simple-flask-app -
执行到容器中并检查烧瓶是否正在运行
docker exec -it simple-flask-app apt-get install curl curl http://127.0.0.1:5000-> 见
200 OK + Flask is running(或类似这样的文字) -
退出 docker 容器
exit -
在你的 Windows 主机上卷曲
curl http://127.0.0.1:5000-> 见
Could not get any response(或类似的东西)
【问题讨论】: