how to link container in docker?

前端 未结 5 645
无人共我
无人共我 2020-11-28 23:05

Here\'s the result when I type docker ps : \"here

in docker,

5条回答
  •  Happy的楠姐
    2020-11-29 00:08

    Linking is a legacy feature. Please use "user defined networks":

    sudo docker network create mynetwork
    

    Then rerun your containers using this network:

    sudo docker run --name rabbitmq -p 8080:80 -d --network mynetwork rabbitmq
    

    Do the same for other containers that you want connected with each other.

    Using "user defined networks", you have an "internal name resolution" at your disposal (somewhat like domain name resolution when visiting websites). You can use the names of the container that you want to refer to, in order to resolve the IP addresses of containers, as long as they are running on the same "user defined network". With this, you can resolve the IP address of the rabbitmq container with its name, within other containers, on the same network.

    All containters on the same "user defined network" will have network connectivity. There is no need for "legacy linking".

提交回复
热议问题