https://blog.csdn.net/fenglailea/article/details/79098246
docker run -d --name node1 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -server -node=node1 -bootstrap-expect=2 &&
docker run -d --name node2 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -server -node=node2 -join $(docker inspect -f '{{.NetworkSettings.IPAddress}}' node1) &&
docker run -d --name node3 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -server -node=node3 -join $(docker inspect -f '{{.NetworkSettings.IPAddress}}' node1) &&
date
JOIN_IP="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' node1)" &&
docker run -d --name node4 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -node=node4 -join $JOIN_IP &&
docker run -d --name node11 -p 8400:8400 -p 8500:8500 -p 8600:53/udp -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -ui -node=node11 -client=0.0.0.0 -join $JOIN_IP &&
date
docker run -d --name node20 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -node=node20 &&
docker exec node20 consul join $(docker inspect -f '{{.NetworkSettings.IPAddress}}' node1)
{
"ID": "userServiceId",
"Name": "userService",
"Tags": [
"primary",
"v1"
],
"Address": "127.0.0.1",
"Port": 8000,
"EnableTagOverride": false,
"Check": {
"DeregisterCriticalServiceAfter": "90m",
"HTTP": "http://www.baidu.com",
"Interval": "10s"
}
}