docker跨主機容器通訊

2021-10-02 00:10:45 字數 801 閱讀 7493

docker:網路模式詳解

路由器位址192.168.1.1route -n檢視

parent=enp7s0的乙太網名用ifcofig查詢

apt install net-tools iputils-ping -y
docker network create --driver=macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=enp7s0 pub_net
$ docker run -itd --name test_pub2 --restart always --hostname test_pub2 --net pub_net tqc/hadoop:

3.0$ docker run -itd --name test_pub1 --restart always --hostname test_pub1 --net pub_net tqc/hadoop:

3.0$ docker run -itd --name test_pub3 --restart always --hostname test_pub3 --net pub_net tqc/hadoop:

3.0

實驗中,

在容器中ping其他容器hostname可以ping到

容器外不行

容器外其他主機是可以用ip訪問容器的

容器中也可以用ip訪問容器外的其他主機

Docker容器跨主機通訊

兩台主機上的docker容器直接通過ip位址進行通訊 各項配置如下 docker version 1.13.1 ip資訊根據個人需求部署 主機1的ip位址為 192.168.1.128 主機2的ip位址為 192.168.1.129 為主機1上的docker容器分配的子網 172.17.1.0 24...

Docker容器跨主機通訊

預設情況下docker容器需要跨主機通訊兩個主機節點都需要在同乙個網段下,這時只要兩個docker容器的宿主機能相互通訊並且該容器使用net網路模式,改實現方式為網橋模式通訊 除此之外我們還可以通過使用第三方工具為不同主機間建立乙個覆蓋網路,使之能夠跨節點通訊,這裡將使用flanneld實現 建立 ...

Docker容器跨主機通訊 路由模式

採用路由模式 1 不同主機的docker子網不同,通過 var docker daemon.json檔案定義。重啟docker服務 systemctl daemon reload systemctl restart docker例如 a主機 bip 172.17.1.252 24 b主機 bip 1...