Docker - 運行 containers 使用在 swarm 模式下建立的 overlay 模式的 network

來源:互聯網
上載者:User

標籤:ssg   doc   隔離   swa   tac   over   logs   for   strong   

前言

在Docker engine v1.12, 使用Swarm可以方便的建立overlay模式的網路,但是它只能被swarm下面的service所使用的,相對於container,這個網路是完全隔離的。 在v1.13,運行 containers 時,可以加入之前在swarm模式下自訂的overlay網路啦!

 

1.  Create swarm in one docker host (172.100.1.17)

$ docker swarm init –advertise-address 172.100.1.17

 

2.   Wait for worker node joined

$ docker swarm join-token worker

 

3.  Join swarm from another docker host (172.100.1.12)

$ docker swarm join --token SWMTKN-1-4kaj1vanh45ihjfgud7nfgaj099gtvrgssg4dxp4rikd1kt1p1-6bwep9vx83oppouz0rfz5scf9 172.100.1.17:2377

 

4.  Create network on manager node (172.100.1.17)

$ docker network create -d overlay --attachable qrtOverlayNet

 

--attachable 是關鍵,它表明這個網路是可以被container所加入。

 

5.  Create container by using overlay network “qrtOverlayNet”

 

172.100.1.17

$ docker run -itd --name mybusybox --network qrtOverlayNet busybox

 

172.100.1.12

$ docker run -itd --name mybusybox12 --network qrtOverlayNet busybox

 

 

6.  Execute container and ping the containers in differenct docker hosts

Ping 12 “busybox” from 17

 

Ping 17 “busybox” from 12

 

Docker - 運行 containers 使用在 swarm 模式下建立的 overlay 模式的 network

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.