In our previous post, we looked at detailed implementation of Docker-Datacenter-In-A-Box (Container-as-a-Service) on VMware ESXi platform. DDC pluggable architecture and open APIs allows flexibility in compute, networking and storage providers used in your CaaS infrastructure without disrupting the application code. Under this blog post, we will talk about Multi-host Docker networking. We will see how overlay networking brings the capability of multi-host networking where the hundreds and thousands of containers can reach each other, even when they are running across different hosts machines and resolve each others DNS names, making service discovery a breeze to name a few.
A Quick brief about Overlay:
Docker’s overlay network driver supports multi-host networking natively out-of-the-box. This support is accomplished with the help of libnetwork, a built-in VXLAN-based overlay network driver, and Docker’s libkv library. Libnetwork provides a network overlay that can be used by your containers so that they appear on the same subnet. The huge bonus is that they can reach each other and resolve each other’s DNS names, making service discovery a breeze.
The overlay network requires a valid key-value store service. Currently, Docker’s libkv supports Consul, Etcd, and ZooKeeper (Distributed store). Before creating a network you must install and configure your chosen key-value store service. The Docker hosts that you intend to network and the service must be able to communicate.
If you have Docker Datacenter installed, it means you already have environment to play around the overlay networking.
Setting up Overlay Networking:
Machine #1: 10.94.214.195
Machine #2: 10.94.214.210
I assume that Docker-datacenter is properly configured and running in your setup. I have DDC Web UI running under Machine #1. Browse to Networks section and click on "Create Network" as shown below:
Suppose you have multiple teams in your floor like DB-team, OS-team, VMware-team and HPC-team and all you want is to create respective network for them. You have multiple Dockerhost running as your VM environment on VMware ESXi 6. Let's go ahead and create a network "DB-network" for DB-team first:
This is equivalent to the below command if you run on your UCP host:
#docker network create --driver overlay DB-network
Ensure that Driver option chosen as "Overlay" and NOT bridge, none or null.Once you click on "Create Network", it should succeed with the acknowledgment as shown below:
We have overlay network setup for DB-team. Interestingly, due to Docker swarm and UCP integration, one can easily see this network from any of UCP client nodes. All you need is run the "docker network ls" utility to see the list of the networks.
Creating container in Overlay Network:
Click on Containers > Deploy Container section to create a container under DB-team overlay network.
We choose "mysql" as image name which will be fetch automatically from the Dockerhub. I have named this new container as "db-mysql-new" for keeping it simple.
Though the above looks a minimal parameters to be considered to bring up the MySQL container but still it might throw warning if you miss out choosing the below parameters:
It will take sometime to get this container running based on your network speed. Once done, it just shows up as shown below:
You can login to any one of Dockerhost machine in the cluster to see the details about this newly created container through docker network inspect utility. From Machine #2, the overlay network and containers running inside this container can be viewed very clearly as shown below:
Let's create mediawiki container under the same network as shown:
You can check under what UCP client node is this mediawiki running:
As shown above, this container is running under Machine #2. Fire up the IP to see the mediawiki default page:
It's just cool..the mediawiki page comes up magically.
You can go ahead and configure Mediawiki to work with MySQL. If you want to use Docker compose, its more simple by clicking over "Compose the application" and it just work flawlessly.
In the forthcoming post, we will look at "Docker Volumes" from Docker-Datacenter (DDC) perspective.