Inter-container communication with help of DNS - Printable Version +- Hilscher Community Forum (https://forum.hilscher.com) +-- Forum: netPI 3 - Docker featuring Industrial Raspberry Pi 3 platform (https://forum.hilscher.com/forum-1.html) +--- Forum: Software (https://forum.hilscher.com/forum-5.html) +--- Thread: Inter-container communication with help of DNS (/thread-277.html) |
Answer - Armin@netPI - December-4th-2017 Docker automatically assigns IP adresses to all those containers started in default bridged network mode. A disadvantage is that each time netPI boots different IP addresses are assigned to these containers which makes a predicable inter-container communication impossible. Instead is it recommended to create a local user-defined network on the system first where Docker is automatically operating a DNS service for. Then, in case a container is started, you can specify this user-defined network as network the container shall run with. The embedded DNS server provides the discovery service for any container created with a valid name. Only then it maintains the mapping between the container name and its IP address on the network the container is connected to. Example: Create two containers with names Container1 and Container2. For both containers specify your user-defined network to connect to. A DNS service will be provided automatically on this network. You can then address the containers over their names with a ping command for example like ping Container1 or ping Container2 instead of using their IP addresses. |