Add docker container to network under two different names

穿精又带淫゛_ 提交于 2019-12-04 14:49:20

This is being specified and implemented in docker/libnetwork issue 737

We'd like a container to be able to join a network under different names, not just the container name.

That will help docker compose too: see docker/compose issue 2312.

When using the --x-networking feature in docker-compose 1.5 (docker-engine 1.9), is it possible to get a "simple name" added to /etc/hosts without knowing the container name beforehand and without using the container_name directive?

Update January 2016:

This is now done in 1.6.0 (RC1 is out)

See "Networking in Compose"

Note: The experimental flags --x-networking and --x-network-driver, introduced in Compose 1.5, have been removed.

See PR 19242 and docker network connect:

--alias option can be used to resolve the container by another name in the network being connected to.

$ docker network connect --alias db --alias mysql multi-host-network container2

Also:

You can use --link option to link another container with a prefered alias

$ docker network connect --link container1:c1 multi-host-network container2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!