version: '3.6'
x-consul: &consul
image: consul:latest
volumes:
- consul:/consul
volumes:
consul:
services:
client:
<<: *consul
ports:
- "8500:8500"
command: "agent -retry-join server-bootstrap -client 0.0.0.0 -bind '{{ GetInterfaceIP \"eth0\" }}' -ui"
depends_on:
- server-bootstrap
deploy:
replicas: 2
server:
<<: *consul
depends_on:
- server-bootstrap
command: "agent -server -retry-join server-bootstrap -client 0.0.0.0 -bind '{{ GetInterfaceIP \"eth0\" }}'"
deploy:
replicas: 2
placement:
constraints: [node.role == manager]
server-bootstrap:
image: consul
command: "agent -server -bootstrap-expect 3 -client 0.0.0.0 -bind '{{ GetInterfaceIP \"eth0\" }}'"
deploy:
placement:
constraints: [node.role == manager]
转载于:https://my.oschina.net/weidedong/blog/1927695