daoli 使用方法_flask

來源:互聯網
上載者:User

運行執行個體:

主節點:

1.1. 建立網路

# docker -H :3380 network create --subnet=11.1.0.0/24 --gateway=11.1.0.1 --driver=daolinet dnet11

1.2. 啟動容器

# docker -H :3380 run -ti -d --net=dnet11 --name test11 centos

# docker -H :3380 run -ti -d --net=dnet12 --name test12 centos

(這時在主節點找不到相應的容器,你可以在子節點看到,在子節點運行# docker inspect test11。)

1.3. 測試容器網路

docker -H :3380 attach test11

[root@9dae2dc3a17e /]# ping 11.1.0.3

PING 11.1.0.3 (11.1.0.3) 56(84) bytes of data.
64 bytes from 11.1.0.3: icmp_seq=1 ttl=64 time=11.9 ms

(通過主節點進入 test11容器,可以ping通test12。)

同樣的方法建立test13,test14在192.168.0.段,進入 test11容器ping 192.168.0.x的IP,是可以ping通的。

1.4 查看節點資訊

# docker -H :3380 info
Containers: 3
 Running: 3
Images: 2
Server Version: swarm/1.2.5
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 1
 localhost.localdomain: 192.168.199.99:2376
  └ ID: 3ZV7:JY4S:77MZ:IQBN:QC3V:TOUU:F5UQ:R5H5:OE5M:RZIG:QGAU:FUPQ
  └ Status: Healthy
  └ Containers: 3 (3 Running, 0 Paused, 0 Stopped)
  └ Reserved CPUs: 0 / 2
  └ Reserved Memory: 0 B / 1.887 GiB
  └ Labels: executiondriver=native-0.2, kernelversion=3.10.0-229.11.1.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-11-21T12:53:45Z
  └ ServerVersion: 1.10.3
Kernel Version: 3.10.0-229.11.1.el7.x86_64
Operating System: linux
Architecture: amd64
Number of Docker Hooks: 2
CPUs: 2
Total Memory: 1.887 GiB
Name: 0cb9ec0b21c3


查看子節點:

# ip r
default via 192.168.199.1 dev daolinet 
11.1.0.0/24 dev tap018e5ccafed  proto kernel  scope link  src 11.1.0.1 


yum -y install net-tools iproute traceroute


# ip netns add ns11

# ip link set tap018e5ccafed netns ns11

目前通過命名空間可以限制容器不同IP段的連通性。


實際的隔離實現和文檔還是有出入的,這同樣說明官方的文檔和代碼是到期的。


# ./daolictl group create G2
G2
# ./daolictl member add --group G2 dnet17
dnet17
# ./daolictl member add --group G1 dnet16
dnet16

# ./daolictl group list
G1
# ./daolictl group show G1
dnet1
dnet11


# ./daolictl connect test21:test22
CONNECTED
# ./daolictl disconnect test21:test22 
Error response from daemon: Post http://127.0.0.1:8080/v1/policy: dial tcp 127.0.0.1:8080: getsockopt: connection refused

# ./daolictl show test21:test22
CONNECTED

# ./daolictl container shownet test21
IPADDRESS           MACADDRESS          GATEWAY             NETWORKNAME         VIPADDRESS
11.1.0.2/24         da:01:53:07:7a:66   11.1.0.1            dnet11            

  
]# ./daolictl container shownet test22
IPADDRESS           MACADDRESS          GATEWAY             NETWORKNAME         VIPADDRESS
10.11.0.2/24        da:01:76:20:41:1d   10.11.0.1           dnet17    



[root@localhost bin]# ./daolictl show test21:test22
CONNECTED

# ./daolictl firewall list
FIREWALL NAME       CONTAINER           GATEWAY IP          GATEWAY PORT        SERVICE PORT


# docker -H :3380 run -ti -d --net=dnet18 --name testssh daolicloud/centos6.6-ssh
8fecb11c7f34173cb4daec865a191d3de736bd508a0ae82c020d5cbfa731546d


# docker -H :3380 run -ti -d --net=dnet18 --name testweb daolicloud/centos6.6-apache
35984c22dc85d0268342800f33af19098fa54aed7f52285a5466d20ffc3a3e34


# ./daolictl firewall create --container testssh --rule 20022:22 fw-ssh
FIREWALL NAME       GATEWAY IP          GATEWAY PORT        SERVICE PORT
fw-ssh              192.168.199.99      22                  20022               


# daolictl firewall show testssh
bash: daolictl: command not found


# ./daolictl firewall show testssh
FIREWALL NAME       GATEWAY IP          GATEWAY PORT        SERVICE PORT
fw-ssh              192.168.199.99      22                  20022             

  
# ssh 192.168.199.99 -p 20022
ssh: connect to host 192.168.199.99 port 20022: Connection refused


# ./daolictl firewall create --container testweb --rule 20080:80 fw-web
FIREWALL NAME       GATEWAY IP          GATEWAY PORT        SERVICE PORT
fw-web              192.168.199.98      80                  20080               


# ./daolictl firewall show testweb
FIREWALL NAME       GATEWAY IP          GATEWAY PORT        SERVICE PORT
fw-web              192.168.199.98      80                  20080             

  
# curl -L http://192.168.199.98:20080
curl: (7) Failed connect to 192.168.199.98:20080; Connection refused


你會發現資訊的添加和顯示是沒有問題,但是功能都是停用。

當然也有可用的功能,比如:

遷移容器

# ./daolictl container move --node NWMG:DGVA:JZBE:WPCL:K24H:U656:ZVZC:NPYE:CXWW:JHLR:XZY5:RYYH testweb
8085edb907b80d4c283023a24a23da038b3c1eb434fa425be150b93c57c5956b 

確實IP等資訊沒有變,遷移到了新的節點上,產生了新的容器ID

# ./daolictl container shownet testweb                                                                                                                                            
IPADDRESS           MACADDRESS          GATEWAY             NETWORKNAME         VIPADDRESS                                                                                                            
10.12.0.6/24        da:01:c6:ba:53:6d   10.12.0.1           dnet18   


理念:http://www.daolicloud.com/document/DaoliNet.pdf

來自:https://github.com/daolinet/daolinet/blob/master/docs/%E4%B8%AD%E6%96%87%E7%94%A8%E6%88%B7%E6%89%8B%E5%86%8C.md

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.