【发布时间】:2019-10-21 16:42:06
【问题描述】:
我有两个 docker-compose 文件,一个包含具有多个 API 的解决方案,另一个包含一些后台运行程序。
问题在于一个后台程序使用在另一个撰写文件中运行的 API。 我希望我可以使用 cotnainername 作为http://[CONTAINERNAME]:80 但这不起作用,网址未知。我认为这是因为它在该撰写文件中不为人所知?这种情况有什么解决办法?
下面是简化的(去掉了其他服务)docker-compose.yml的
文件1:
version: '3.3'
services:
firstapi:
image: firstapi:latest
container_name: firstapi
ports:
- "4005:80"
文件2:
version: '3.3'
services:
firsttool:
image: firsttool:latest
container_name: firsttool
environment:
- Endpoint_FirstAPI=http://firstapi:80
【问题讨论】:
-
除非您另有说明(请参阅docs.docker.com/compose/compose-file/…),否则每个撰写文件还将定义一个单独的网络。 Service-name-as-hostname 只能在一个网络中使用。
标签: docker docker-compose endpoint