问题:
从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 应用)
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
进入容器并检查 Flask 是否正在运行
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
curl http://127.0.0.1:5000
-> 看到
Could not get any response
(或类似文本)