Docker Networking: Auto-discovering host names in a bridge network

后端 未结 1 756
渐次进展
渐次进展 2020-12-10 16:22

I am trying to get the following pretty basic (or so I thought) networking setup to work using Docker 1.9:

  • I have multiple containers that run services, e.g. a
相关标签:
1条回答
  • 2020-12-10 17:06

    docker 1.10, and PR 19242 can help:

    docker create --net-alias=[]: Add network-scoped alias for the container
    

    docker 1.10 has a new section Network-scoped alias:

    While links provide private name resolution that is localized within a container, the network-scoped alias provides a way for a container to be discovered by an alternate name by any other container within the scope of a particular network.
    Unlike the link alias, which is defined by the consumer of a service, the network-scoped alias is defined by the container that is offering the service to the network.

    Continuing with the above example, create another container in isolated_nw with a network alias.

    $ docker run --net=isolated_nw -itd --name=container6 --net-alias app busybox
    8ebe6767c1e0361f27433090060b33200aac054a68476c3be87ef4005eb1df17
    

    Now let us connect container6 to the local_alias network with a different network-scoped alias.

    $ docker network connect --alias scoped-app local_alias container6
    

    container6 in this example now is aliased as app in network isolated_nw and as scoped-app in network local_alias.

    0 讨论(0)
提交回复
热议问题