Overlay network is created between two containers, and VXLan tunnel connects the containers through a bridge.
This setup has been deployed using the Docker experimental version, which keeps on updating regularly and might not support some of the features:
docs
folder:$ git clone $ cd libnetwork/docs
$ vagrant up Bringing machine 'consul-server' up with 'virtualbox' provider... Bringing machine 'net-1' up with 'virtualbox' provider... Bringing machine 'net-2' up with 'virtualbox' provider... ==> consul-server: Box 'ubuntu/trusty64' could not be found. Attempting to find and install... consul-server: Box Provider: virtualbox consul-server: Box Version: >= 0 ==> consul-server: Loading metadata for box 'ubuntu/trusty64' consul-server: URL: https://atlas.hashicorp.com/ubuntu/trusty64 ==> consul-server: Adding box 'ubuntu/trusty64' (v20151217.0.0) for provider: virtualbox consul-server: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20151217.0.0/providers/virtualbox.box ==> consul-server: Successfully added box 'ubuntu/trusty64' (v20151217.0.0) for 'virtualbox'! ==> consul-server: Importing base box 'ubuntu/trusty64'... ==> consul-server: Matching MAC address for NAT networking... ==> consul-server: Checking if box 'ubuntu/trusty64' is up to date... ==> consul-server: Setting the name of the VM: libnetwork_consul-server_1451244524836_56275 ==> consul-server: Clearing any previously set forwarded ports... ==> consul-server: Clearing any previously set network interfaces... ==> consul-server: Preparing network interfaces based on configuration... consul-server: Adapter 1: nat consul-server: Adapter 2: hostonly ==> consul-server: Forwarding ports... consul-server: 22 => 2222 (adapter 1) ==> consul-server: Running 'pre-boot' VM customizations... ==> consul-server: Booting VM... ==> consul-server: Waiting for machine to boot. This may take a few minutes... consul-server: 101aac79c475b84f6aff48352ead467d6b2b63ba6b64cc1b93c630489f7e3f4c ==> net-1: Box 'ubuntu/vivid64' could not be found. Attempting to find and install... net-1: Box Provider: virtualbox net-1: Box Version: >= 0 ==> net-1: Loading metadata for box 'ubuntu/vivid64' net-1: URL: https://atlas.hashicorp.com/ubuntu/vivid64 ==> net-1: Adding box 'ubuntu/vivid64' (v20151219.0.0) for provider: virtualbox net-1: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/vivid64/versions/20151219.0.0/providers/virtualbox.box contd...
$ vagrant status Current machine states: consul-server running (virtualbox) net-1 running (virtualbox) net-2 running (virtualbox) This environment represents multiple VMs. The VMs are all listed above with their current state. For more information about a specific VM, run `vagrant status NAME`.
$ vagrant ssh net-1 Welcome to Ubuntu 15.04 (GNU/Linux 3.19.0-42-generic x86_64) * Documentation:https://help.ubuntu.com/ System information as of Sun Dec 27 20:04:06 UTC 2015 System load: 0.0 Users logged in: 0 Usage of /: 4.5% of 38.80GB IP address for eth0: 10.0.2.15 Memory usage: 24% IP address for eth1: 192.168.33.11 Swap usage: 0% IP address for docker0: 172.17.0.1 Processes: 78 Graph this data and manage this system at: https://landscape.canonical.com/ Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud
/etc/hosts
file in order to verify that it has the overlay bridge specification, which was previously deployed, and it automatically connects to it on the launch:$ docker run -it --rm ubuntu:14.04 bash Unable to find image 'ubuntu:14.04' locally 14.04: Pulling from library/ubuntu 6edcc89ed412: Pull complete bdf37643ee24: Pull complete ea0211d47051: Pull complete a3ed95caeb02: Pull complete Digest: sha256:d3b59c1d15c3cfb58d9f2eaab8a232f21fc670c67c11f582bc48fb32df17f3b3 Status: Downloaded newer image for ubuntu:14.04 root@65db9144c65b:/# cat /etc/hosts 172.21.0.4 2ac726b4ce60 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.21.0.3 distracted_bohr 172.21.0.3 distracted_bohr.multihost 172.21.0.4 modest_curie 172.21.0.4 modest_curie.multihost
net-2
as well and can verify the working of the overlay network driver as both the containers will be able to ping each other in spite of being deployed on different hosts.In the previous example, we started the Docker container with the default options and they got automatically added to a multi-host network of type overlay.
We can also creat a separate overlay bridge and add containers to it manually using the --publish-service
option, which is part of Docker experimental:
vagrant@net-1:~$ docker network create -d overlay tester 447e75fd19b236e72361c270b0af4402c80e1f170938fb22183758c444966427 vagrant@net-1:~$ docker network ls NETWORK ID NAME DRIVE 447e75fd19b2 tester overlay b77a7d741b45 bridge bridge 40fe7cfeee20 none null 62072090b6ac host host
The second host will also see this network and we can create containers added to the overlay network in both of these hosts by using the following option in the Docker command:
$ docker run -it --rm --publish-service=bar.tester.overlay ubuntu:14.04 bash
We will be able to verify the working of the overlay driver as both the containers will be able to ping each other. Also, tools such as tcpdump, wireshark, smartsniff, and so on can be used to capture the vXLAN package.