Discovering and load balancing containers
In the previous recipe, we looked at the benefits of a user-defined bridge network and the steps to create and examine a user-defined bridge network. In this recipe, we will build a container topology, as depicted in the following diagram:

In this topology, we will launch container1
and container2
like a service and use a transient container to demonstrate the following capabilities of the user-defined bridge network:
- Service discovery through an embedded DNS server
- DNS-based load balancing
Getting ready
Before we begin, ensure that the Docker daemon is running.
How to do it...
Perform the following the steps:
Let's start off by spinning two containers,
container1
andcontainer2
, by connecting them to the user-defined bridge networkcookbook
using thedocker container run
command, as shown in the following screenshot:

Here, the --network-alias
option helps us to group multiple containers with a single alias name and load balance using the embedded DNS. The...