Docker swarm
阿新 • • 發佈:2017-09-04
cte exp ble nbsp consul rouge rem style ack 啟動 Swarm manager
Docker swarm 概述
Docker Swarm是Docker的本地群集,使用Docker Machine是用戶首次使用Swarm的最佳方法
創建一個Docker集群
創建主機並生成令牌
列出系統上的機器
[[email protected] ~]# docker-machine ls
創建一個名為 lianxi 的主機
[[email protected] ~]# docker-machine create -d virtualbox lianxi
將l ianxi 主機的配置裝入shell
[[email protected] ~]# docker-machine env lianxi [[email protected]~]# eval $(docker-machine env lianxi)
使用Docker Swarm 生成發現令牌(以下swarm create
命令在容器中運行命令)
[[email protected] ~]# docker-machine ssh lianxi [email protected]:~$ docker run swarm create Unable to find image ‘swarm:latest‘ locally latest: Pulling from library/swarm ad8c679cee1a: Pull complete 97186f5f56a9: Pull complete 821a304aaa0d: Pull complete Digest: sha256:1a05498cfafa8ec767b0d87d11d3b4aeab54e9c99449fead2b3df82d2744d345 Status: Downloaded newer image forswarm:latest Token based discovery is now deprecated and might be removed in the future. It will be replaced by a default discovery backed by Docker Swarm Mode. Other mechanisms such as consul and etcd will continue to work as expected. e2edcabb86d25787d0182101b94f292e #令牌
將令牌保存到有個安全的地方,下一步會用到
啟動 Swarm manager
創建一個 swarm manager 和兩個節點
退出lianxi 容器
[email protected]:~$ exit
創建一個swarm manage,命令格式如下
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token:/令牌 \ swarm-master
例如
[[email protected] ~]# docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://8c33b2a02009172d45c47188d65daf53 \ swarm-master
創建一個群組節點
[[email protected] ~]# docker-machine create -d virtualbox --swarm --swarm-discovery token://8c33b2a02009172d45c47188d65daf53 \ swarm-agent-00
添加另一個代理調用swarm-agent-01
[[email protected] ~]# docker-machine create -d virtualbox --swarm --swarm-discovery token://8c33b2a02009172d45c47188d65daf53 \ swarm-agent-01
Docker swarm