To support container Cross host communication, Docker provides overlay driver, allowing users to create overlay networks based on Vxlan. Vxlan can encapsulate two-tier data into UDP for transmission, Vxlan provides the same Ethernet two-tier service as the VLAN, but with greater scalability and flexibility. More detailed information about Vxlan can be referenced in the relevant chapters of Cloudman's 5-minute play OpenStack every day.
Docerk Overlay network requires a Key-value database to hold network state information, including network, Endpoint, IP, etc. Consul, ETCD and zookeeper are all Docker-supported Key-vlaue software, and we use consul here. Description of the experimental environment
We will directly use the experimental environment created by the previous chapter Docker-machine. Implement a variety of cross-site networking scenarios on the Docker host Host1 (192.168.56.104) and Host2 (192.168.56.105), deploying supported components on the 192.168.56.101, such as consul.
The easiest way to do this is to run the consul in a container:
Docker run-d-P 8500:8500-h Consul--name consul Progrium/consul-server-bootstrap
After the container is started, you can access consul through http://192.168.56.101:8500.
Next, modify the configuration file/etc/systemd/system/docker.service for host1 and Host2 Docker daemon.
--CLUSTER-STORE Specifies the address of the consul.
--cluster-advertise tells consul his or her connection address.
Restart Docker daemon.
Systemctl Daemon-reload
Systemctl Restart Docker.service
Host1 and Host2 are automatically registered in the consul database.
Ready, the experimental environment is as follows:
The next section creates a overlay network.