【发布时间】:2015-11-25 11:38:54
【问题描述】:
我有一个简单的撰写文件,其中有三个服务 A、B 和 C。A 和 B 都依赖于 C(即有 links 到 C)。这是docker-compose.yml的简化摘录:
kafka:
image: spotify/kafka
environment:
ADVERTISED_PORT: 9092
ports:
- "2181:2181"
- "9092:9092"
ServiceA:
image: elsoufy/myimage
command: ./mycommand -role producer -queue kafka:9092
ports:
- "8080"
ServiceB:
image: elsoufy/myimage
command: ./mycommand -role consumer -queue kafka:9092
我已经在 AWS 上设置了一个 Docker swarm,并通过 consul key-store 启用了覆盖网络。我一直在努力让它正常工作(我不得不手动将机器的内核升级到linux 3.16)。
我使用的是 Docker 1.9
Client:
Version: 1.9.0
API version: 1.21
Go version: go1.4.3
Git commit: 76d6bc9
Built: Tue Nov 3 19:20:09 UTC 2015
OS/Arch: darwin/amd64
Server:
Version: 1.9.0
API version: 1.21
Go version: go1.4.3
Git commit: 76d6bc9
Built: Tue Nov 3 19:20:09 UTC 2015
OS/Arch: linux/amd64
我可以使用docker-compose up -d 成功启动组合,但是ServiceA 和ServiceB 在多次尝试连接到kafka 后崩溃,因为他们找不到它。当我尝试使用显式 links 并为此应用启用覆盖时 I get an error:
docker-compose --x-networking --x-network-driver=overlay up
links, which are not compatible with Docker networking and will be ignored. Future versions of Docker will not support links - you should remove them for forwards-compatibility.
当我想启用多主机时,我似乎无法使用links!但是,我如何在容器之间运行一个组合应用程序并在 docker swarm 上扩展容器?
【问题讨论】:
-
docker 1.9 中的新网络功能使用共享网络上的 IP 主机发现作为链接的替代。请参阅以下答案:stackoverflow.com/questions/33785804/…
-
这条消息只是一个警告(不是错误)。我认为它应该在消息上有一个
Warning前缀,对吧?它只是在复制/粘贴中被切断。 -
@dnephin 我没有完整的消息,我在看到问题一天后发布了这个帖子。
-
@MarkO'Connor 感谢您的链接,看起来我已经手动运行了我的容器,那么 compose 是干什么用的?
-
@MarkO'Connor 当我尝试 tomcat 示例时,服务发现工作正常,但是当我尝试使用 zookeeper(使用 docker-compose.yml 运行)和 kafka(手动运行)时,发现确实有效不工作。
标签: amazon-web-services networking docker docker-compose docker-machine