Docker compose似乎是在我开始时自动设置hosts文件中的链接:
consul:
image: registry.systems.com/consuld
container_name: consul
ports:
- "8400:8400"
- "8500:8500"
- "53:8600/udp"
environment:
- IP=192.168.99.100
hostname: dockermachine
registrator:
image: gliderlabs/registrator:latest
container_name: registrator
command: consul://consul:8500
volumes:
- "/var/run/docker.sock:/tmp/docker.sock"
links:
- consul
kv-registration:
image: registry.systems.com/nativ/consul-local-kv-registration
container_name: kv-registration
links:
- consul
rabbitmq:
image: rabbitmq
container_name: rabbitmq
ports:
- 4369:4369
- 5672:5672
- 15672:15672
- 25672:25672
mongodb:
image: mongo
container_name: mongodb
ports:
- 27017:27017
- 28017:28017
mio-events-service:
image: registry.systems.com/mio-events-service:1.0.190
container_name: mio-events-service
ports:
- 18113:18113
extra_hosts:
- "dockermachine:192.168.99.100"
即。我不必在docker-compose.yml中提供“links:”元素来获取容器之间的链接。这似乎与文档相矛盾。任何想法为什么这样做?
由于
尼克
更新
这是我的撰写文件
{{1}}
答案 0 :(得分:2)
我认为您正在使用--x-networking
替换链接,并为同一网络中的每个容器添加这些主机条目。