The method of using the overlay of the container in different hosts communicate
// close selinux (set tolerance mode)
// use consul mirror, run consul Service
docker run -d -p 8500:8500 -h consul --name consul --restart=always progrium/consul -server -bootstrap
-h: hostname
-server: representatives of server-side,
-bootstrap: self-elected as Leader
// need to explain, consul service can be understood as a data center, he can collect different information ip or ports on the host.
// modify configuration files docker to three hosts, for example, aims to join the cluster.
vim /usr/lib/systemd/system/docker.service
// restart docker
systemctl daemon-reload
systemctl restart docker.service
// can be verified: Access 8500 port, the following page
// create a new network, type of overlay networks.
docker network create -d overlay ov_net1
-d: Specifies the network type
// check will find a new type of overlay network, network range is global network. Since the three hosts have been connected by a consul, so the three hosts have it will find the network.
Then based on this network, on different hosts, each container to create several communication between the containers. (Into the container, respectively, ping ip other containers tested)
docker run -itd --name t1 --network ov_net1 busybox
-network: network type of the container