The swarm routing mesh
If you have paid attention, then you might have noticed something interesting in the last chapter. We had the pets
application deployed and it resulted in an instance of the web service being installed on the three nodes – node-1
, node-2
, and node-3
.
Yet, we were able to access the web service on node-1
with localhost
and we reached each container from there. How is that possible? Well, this is due to the so-called Swarm routing mesh. The routing mesh makes sure that when we publish a port of a service, that port is then published on all nodes of the Swarm. Hence, network traffic that hits any node of the Swarm and requests to use a specific port will be forwarded to one of the service containers by routing the mesh. Let’s look at the following diagram to see how that works:
Figure 15.1 – Docker Swarm routing mesh
In this situation, we have three nodes, called Host A, Host B, and Host C, with the IP addresses...