我有一个运行在容器(localhost:8090
)外部的Web应用。
如何从docker-compose
网络中的容器中访问它?
我试图按照this的回答为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:
答案 0 :(得分:2)
将var options = {
hostname: 'us-central1-dpduk-s-test-d1.cloudfunctions.net',
path: '',
method: 'GET',
headers:{
Authorization: ' Bearer A416EB2A-5B7F-4A85-9E32-75CDB8F4F0F6'
}
}, routesETA;
添加到您的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"
会侦听主机端口8080,并且能够连接到graphql-engine
为确保其正常工作,请确认Docker主机上的localhost:8090
文件位于/etc/hosts
容器内部。