Here is a sample test to show how Docker Swarm and Docker Compose simplify network management.
We’ll deploy a topology of 3 containers and see how they can reach each other. In the first case, we deploy it on a single node. In the second case, we deploy it on a 2 host swarm cluster.
The Swarm cluster is created as a Swarm Azure Container Service instance with the main following parameters:
- Orchestrator configuration: Swarm (btw, other option for ACS is DC/OS)
- Agent count: 2
- Agent virtual machine size: (leave default)
- Master count: 1
- DNS prefix for container service: myacs
Two files are created
The Dockerfile contains:
The docker-compose.yml file has the following content:
Here is what I get on the single box:
Let’s now do the same from the master node of my ACS cluster.
network information was added to the docker-compose.yml file:
and here is the result of the test:
We have containers in a common network which is described only thru docker means.
This works on a single host, and also on multiple hosts (in the example, a host had 1 container, another host had 2 of the 3 containers).