下载 consul 二进制包并启动

wget https://releases.hashicorp.com/consul/0.9.2/consul_0.9.2_linux_amd64.zip
unzip consul_0.9.2_linux_amd64.zip
mv consul /usr/bin/consul && chmod +x /usr/bin/consul
nohup consul agent -server -bootstrap -ui -data-dir /var/lib/consul -client=192.168.1.198 -bind=192.168.1.198
&>/var/log/consul.log &

节点配置 docker 守护进程连接 consul

vim /etc/default/docker

DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store consul://172.16.120.34:8500 --cluster-advertise 172.16.120.34:2375"

systemctl restart docker

创建overlay网络

docker network create -d overlay multi_host

测试互通

docker run -itd --net=multi_host busybox