[英]Docker-compose link containers in settings file
I have following docker-compse.yml: 我有以下docker-compse.yml:
version: '2'
services:
api:
build: api/.
command: make run
depends_on:
- postgres
links:
- postgres:postgres
processor:
build: processor/.
command: make run
ports:
- "9000:9000"
links:
- api:api
In my processor I have following setting.ini: 在我的处理器中,我有以下setting.ini:
api=http://api:7000/
And Dockerfile for processor looks like following: 用于处理器的Dockerfile如下所示:
ADD ./src/processor/setting.ini /etc/app/processor/setting.ini
When running this via docker-compose up
I got errors that processor couldn't see the api. 通过
docker-compose up
运行此程序时,出现错误,表明处理器看不到api。 Is it possible to link them? 是否可以链接它们?
Yes, just add the link to your processor service: 是的,只需将链接添加到您的处理器服务即可:
version: '2'
services:
api:
build: api/.
command: make run
depends_on:
- postgres
links:
- postgres:postgres
processor:
build: processor/.
links:
- api:api
command: make run
ports:
- "9000:9000"
I moved your links
section directly into your definition of processor
. 我将您的
links
部分直接移到您的processor
定义中。 This is where links should be defined (see Compose File Reference ). 这是应在其中定义链接的位置(请参阅撰写文件参考 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.