When creating a database cluster we need the different containers to be able to easily communicate each other but also keep them isolated. That’s why we want to use a Docker bridge network:
From Docker documentation:
On a user-defined bridge network, containers can resolve each other by name or alias.
So if we have to delete and recreate a container and it get a new IP address, the other containers will still communicate with the newly created by using the name we assign to it instead of the IP.
For this you first need to create a network:
$ docker network create --driver bridge pato-net
and then assign this network to the container when you are creating it:
$ docker run ... --network pato-net ...
Also from documentation:
Using a user-defined network provides a scoped network in which only containers attached to that network are able to communicate.
So if you have two or more clusters within your Docker host they will remain independent if we assign them a different network.