我试图使用docker容器测试我的web应用程序,但当我试图通过浏览器访问它时,我无法看到它。在
docker compose文件看起来像
version: '2'
services:
db:
image: postgres
volumes:
- ~/pgdata:/var/lib/postgresql/data/pgdata
environment:
POSTGRES_PASSWORD: "dbpassword"
PGDATA: "/var/lib/postgresql/data/pgdata"
ports:
- "5432:5432"
web:
build:
context: .
dockerfile: Dockerfile-web
ports:
- "5000:5000"
volumes:
- ./web:/web
depends_on:
- db
backend:
build:
context: .
dockerfile: Dockerfile-backend
volumes:
- ./backend:/backend
depends_on:
- db
dockerfile web看起来像
^{pr2}$ip是我的机器
docker机器ip 192.168.99.100
但当我试着 http://192.168.99.100:5000/ 在我的浏览器里,它只是说网站无法访问。 它似乎在拒绝连接。在
当我在浏览器中ping数据库时,我可以在日志中看到我的数据库响应 http://192.168.99.100:5432/
所以我试着把它放进容器里
$ docker exec 3bb5246a0623 wget http://localhost:5000/
--2016-07-23 05:25:16-- http://localhost:5000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5000... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:5000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34771 (34K) [text/html]
Saving to: ‘index.html.1’
0K .......... .......... .......... ... 100% 5.37M=0.006s
2016-07-23 05:25:16 (5.37 MB/s) - ‘index.html.1’ saved [34771/34771]
有人知道我如何通过浏览器显示我的web应用程序吗?在
我必须为我的烧瓶应用程序启用外部可见性。 你可以在这里看到 Can't connect to Flask web service, connection refused
相关问题 更多 >
编程相关推荐