Docker assigns an IP to a container dynamically from a pool of available addresses. While this is good in some ways, it creates a problem when you are running containers that need to communicate with each other. You just cannot know when building an image what its IP address is going to be. Your first instinct might be to start the containers, then log in to them (via
exec), and set the IP addresses of the other containers manually. But remember, this IP address can change when a container restarts, so then you would have to manually log in to each container and enter the new IP address. Could there be a better way? Yes, there is.
Service discovery is a collection of everything that needs to be done to let services know ...