Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

 
alt

Daniel Nashed

 

    Docker Container name resolution

    Daniel Nashed  22 April 2023 08:56:21

    Docker container name resolution can be tricky.
    In bridge network the container runs in a kind of NAT work and get a private IP address assigned form it's pool.

    If you need to connect multiple containers, you might want to use the local network, instead of the public IP.
    But how do you connect between the containers in that case, if the container gets a dynamic IP address assigned on start?

    Bridge network with Docker DNS


    The default bridge network does not use an own DNS server, which leaves you only to host entries added to your container at startup.

    But if you create your own bridge network, the host name you assign to your container, is resolvable by other containers on the same network.
    The container also gets the Docker DNS server assigned.

    https://docs.docker.com/config/containers/container-networking/#dns-services

    Host entries don't work for all applications, depending how they resolve the address.
    But this configuration option allows you to use full DNS resolution for your local hosts.

    The hostname of your container gets the local IP address assigned.

    Using your local IP address via DNS inside your container

    In some cases you also need to bind to specific names. But you want them to resolve to the local address and not the external address.
    In that case the local DNS name of your container is also very useful!

    Choosing the right name

    To ensure your name resolution does not go into a loop and to return the local address assigned to the container, you should not use the external DNS name.
    Instead you could usea name like this: pluto.docker.local
    This name will point to the local IP and can be used by all hosts on the same network to access your server.

    There are a couple of use cases. One very interesting use case is service discovery.
    If you run a load balancer like NGINX, the local balancer can resolve the host name for the back-end using this name.



    Important detail to keep in mind


    The important part is that this that the local DNS server is only used when you create your own Docker network (e.g. docker create network domino-net).
    For the default network the host's DNS is used by default.





    Links

      Archives


      • [HCL Domino]
      • [Domino on Linux]
      • [Nash!Com]
      • [Daniel Nashed]