Docker linked containers, Docker Networks, Compose Networks - how should we now 'link' containers

落爺英雄遲暮 提交于 2019-12-05 06:01:46

If 2 containers are in the same network, are the same ENV vars automatically exposed on the containers as if they were linked?

no, you would now have to use the container names as their hostnames. The new network feature has no idea which ports will be used. Think of this as 2 computers plugged on the same network hub. Both can address the other one by its hostname.

is the hosts file updated with the correct container name / ip addresses ? Even after a docker restart ?

yes, /etc/hosts files for all containers which are part of a network will be updated live by the docker engine.

I can't see in the docs how a container can find the location of another in its network?

Using the container name. See the Connect containers section of the Work with network commands doc: Once connected, the containers can communicate using another container’s IP address or name.

Also, compose looks to have a simple set up for linking containers, and may automate some of this - would compose be the way to go for defining multi container apps? Or is it too soon to run it in production?

Compose supports the new network feature as beta by offering the --x-networking option. You should not use it in production yet (current Compose version is 1.5).

Furthermore, the current implementation is a bit inconvenient as we must use the full container name which is composed of the project name + _ + container name + _1. The documentation says the next version (current one is 1.5) will improve this so that we should not have to worry about the project name to address containers.

Does compose support multiple host configuration as well?

Yes, in conjonction with Swarm as detailed in the overlay network documentation

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