[英]how to access a localhost app from a container in docker-compose
I have a web app running outside of a container ( localhost:8090
).我有一个在容器外运行的 web 应用程序(
localhost:8090
)。
How can I access it from within a container in a docker-compose
network?如何从
docker-compose
网络中的容器内访问它?
I tried to follow this answer that help for docker
.我试图遵循这个对
docker
有帮助的答案。
version: '3.6'
services:
postgres:
image: postgres
restart: always
volumes:
- db_data:/var/lib/postgresql/data
networks:
- host
graphql-engine:
image: hasura/graphql-engine:v1.0.0-beta.6
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
HASURA_GRAPHQL_AUTH_HOOK: "http://localhost:8090/verify"
volumes:
db_data:
Add network_mode: "host"
to your graphql-engine:
and remove port mapping:将
network_mode: "host"
添加到您的graphql-engine:
并删除端口映射:
graphql-engine:
image: hasura/graphql-engine:v1.0.0-beta.6
depends_on:
- "postgres"
restart: always
network_mode: "host"
environment:
HASURA_GRAPHQL_AUTH_HOOK: "http://localhost:8090/verify"
graphql-engine
would listen on host port 8080 and would be able to connect to localhost:8090
graphql-engine
将侦听主机端口 8080 并能够连接到localhost:8090
To make sure it worked, verify /etc/hosts
file from the docker host is inside graphql-engine
contianer.为确保它正常工作,请验证 docker 主机中的
/etc/hosts
文件是否位于graphql-engine
中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.