其他分享
首页 > 其他分享> > Docker--容器互联

Docker--容器互联

作者:互联网

  1. 容器互联之--link
    1.   
    2. docker network inspect  容器id;
    3.  

       

    4.  

       

       

       

  2.  容器互联之自定义网络:

    1. #启动tomcat,使用我们自己创建的网络
      [root@localhost ~]# docker run -d -P --name tomcat02 --net mynet mytomcat 1272ff88b41f5e26e959b3623b2961e4631d173d0ed0f37b5d50af600afae05d [root@localhost ~]# docker run -d -P --name tomcat01 --net mynet mytomcat 28f0e87af41faa34e02cb2aaad3f150a3cf065135f34bb567b161bb326bb91ff
      #查看我们自定义网络的详细信息 [root@localhost ~]# docker network inspect mynet [ { "Name": "mynet", "Id": "05487626ee18cfe0d9392c3f9bb10662318a3ded21d7b046d133a958baa5c871", "Created": "2021-10-04T20:27:27.091862559+08:00", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": {}, "Config": [ { "Subnet": "192.168.0.0/16", "Gateway": "192.168.0.1" } ] }, "Internal": false, "Attachable": false, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false,
      #在我们自定义的网络内多出了两个容器 "Containers": { "1272ff88b41f5e26e959b3623b2961e4631d173d0ed0f37b5d50af600afae05d": { "Name": "tomcat02", "EndpointID": "f5723c5551570f564aada98161b7f653d191f92cf25dfcb4bc3cf20d36c61dfc", "MacAddress": "02:42:c0:a8:00:02", "IPv4Address": "192.168.0.2/16", "IPv6Address": "" }, "28f0e87af41faa34e02cb2aaad3f150a3cf065135f34bb567b161bb326bb91ff": { "Name": "tomcat01", "EndpointID": "c85b0655fbfe5cda99ea722f191a4b0807b8d37b50af9101f0bc4dcdd818c516", "MacAddress": "02:42:c0:a8:00:03", "IPv4Address": "192.168.0.3/16", "IPv6Address": "" } }, "Options": {}, "Labels": {} } ]

       

    2.  

  3.  网络连通:

    1.  

       

标签:互联,docker,false,容器,--,192.168,Docker,mynet
来源: https://www.cnblogs.com/zzhAylm/p/15367179.html