有了新的功能強大、簡單易用的Swarm mode集羣,基本就不須要老的Docker Swarm主機集羣了。兩個概念必定要區分開!不然會給Docker中的 Swarm mode 的使用形成麻煩。不能把這兩個概念混爲一談:使用Docker machine create 命令自帶的--swarm --swarm-master參數建立了一個Docker Swarm 集羣,卻想使用只有Swarm mode 才支持的swarm、node、service 等子命令,確定會報錯。node
老的Docker Swarm使用獨立的外部KV存儲(好比Consul、etcd、zookeeper),搭建獨立運行的Docker主機集羣,用戶像操做單臺Docker 機器同樣操做整個集羣,Docker Swarm把多臺Docker主機當作一臺Docker主機來管理。在docker 1.12版以前,只有搭建Docker Swarm集羣,沒有Swarm mode之說,結合machine和compose來操做全部Docker機器。這樣的集羣也是能夠正常運行的,沒有任何問題。web
新的Swarm mode 是在docker 1.12版本中集成到 Docker 引擎中的,引入服務的概念,提供了衆多的新特性,好比:具備容錯能力的去中心化設計、內置服務發現、負載均衡、路由網格、動態伸縮、滾動更新、安全傳輸等。使得Docker 原生的Swarm mode集羣具有與Mesos、Kubernetes叫板的實力。docker
參考連接及轉載的內容:express
一、Swarm、Swarmkit和Swarm模式傻傻分不清安全
若是不熟悉的人該問了,這個和以前的Docker Swarm(在Docker 1.6時就有了)有什麼不一樣麼?以前的Swarm要棄用了麼?不是前幾天剛出個Swarmkit麼?話說也是佩服Docker能把產品搞得這麼複雜,弄出這麼多名稱,也真是讓人醉了。網絡
相信抱有此疑問的人不在少數。這裏,咱們就來簡單看一下Docker Swarm(以前和Docker machine、Docker compose並稱三劍客)、swarmkit和Swarm mode之間的區別。app
Docker Swarm負載均衡
獨立於Docker engineless
須要額外的KV存儲(也能夠用Docker Hub的token)學習
沒有服務模型
與Docker machine的集成
使用Docker CLI
Swarmkit
在Docker 1.12 RC以前的幾周,Docker 發佈了 Swarmkit。這是一個獨立的、開源的容器編排項目。
它的特色是:
使用本身的CLI(swarmd負責管理,swarmctl用於控制)
沒有服務發現、負載均衡和路由功能
提供編排和調度服務
是Swarm mode的基礎
Swarm mode
集成到了Docker engine中(docker swarm子命令)
不須要額外的KV存儲
支持服務模型(及task概念)以及相應的擴容縮容、服務發現、滾動升級、路由和負載均衡等
加密通訊
尚未和Docker machine與Docker compose集成
使用Docker CLI
Swarm mode基於Swarmkit編寫
Docker engine Swarm是一個對Swarm的重大升級,由於提出了service這個概念,而不是再以容器做爲主要管理對象單元,而是以更符合邏輯的服務爲單位進行管理和調度,其下才是容器。估計這也是向Kubernetes學習的結果,而單獨的Swarm不久以後將會退出歷史舞臺吧,集成到Docker engine的Swarm則將會是Docker搶佔企業級市場的重要攻擊性武器。競爭將會異常激烈,但Docker得勝算不能說很大,畢竟如今Mesos 1.0發佈以後,都開始Docker daemon
-less了。
一句話來講,忘記Docker Swarm吧,知道有個Swarmkit,要用就用Docker Swarm Mode。
二、Swarm、SwarmKit、Swarm mode 對比
http://blog.csdn.net/halcyonbaby/article/details/52037091
三、Swarm mode overview
https://docs.docker.com/engine/swarm/
To use Docker Engine in swarm mode, install the Docker Engine v1.12.0 or later from the Docker releases GitHub repository. Alternatively, install the latest Docker for Mac or Docker for Windows Beta.
Docker Engine 1.12 includes swarm mode for natively managing a cluster of Docker Engines called a swarm. Use the Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior.
If you’re using a Docker version prior to v1.12.0, see Docker Swarm.
Swarm mode CLI commands
Explore swarm mode CLI commands
swarm init
swarm join
service create
service inspect
service ls
service rm
service scale
service ps
service update
Feature highlights
Cluster management integrated with Docker Engine: Use the Docker Engine CLI to create a swarm of Docker Engines where you can deploy application services. You don’t need additional orchestration software to create or manage a swarm.
去中心化設計Decentralized design: Instead of handling differentiation between node roles at deployment time, the Docker Engine handles any specialization at runtime. You can deploy both kinds of nodes, managers and workers, using the Docker Engine. This means you can build an entire swarm from a single disk image.
引入服務模型Declarative service model: Docker Engine uses a declarative approach to let you define the desired state of the various services in your application stack. For example, you might describe an application comprised of a web front end service with message queueing services and a database backend.
動態伸縮Scaling: For each service, you can declare the number of tasks you want to run. When you scale up or down, the swarm manager automatically adapts by adding or removing tasks to maintain the desired state.
Desired state reconciliation: The swarm manager node constantly monitors the cluster state and reconciles any differences between the actual state and your expressed desired state. For example, if you set up a service to run 10 replicas of a container, and a worker machine hosting two of those replicas crashes, the manager will create two new replicas to replace the replicas that crashed. The swarm manager assigns the new replicas to workers that are running and available.
多主機網絡Multi-host networking: You can specify an overlay network for your services. The swarm manager automatically assigns addresses to the containers on the overlay network when it initializes or updates the application.
服務發現Service discovery: Swarm manager nodes assign each service in the swarm a unique DNS name and load balances running containers. You can query every container running in the swarm through a DNS server embedded in the swarm.
負載均衡Load balancing: You can expose the ports for services to an external load balancer. Internally, the swarm lets you specify how to distribute service containers between nodes.
安全通信Secure by default: Each node in the swarm enforces TLS mutual authentication and encryption to secure communications between itself and all other nodes. You have the option to use self-signed root certificates or certificates from a custom root CA.
滾動升級Rolling updates: At rollout time you can apply service updates to nodes incrementally. The swarm manager lets you control the delay between service deployment to different sets of nodes. If anything goes wrong, you can roll-back a task to a previous version of the service.
四、Definition of: swarm mode
https://docs.docker.com/glossary/?term=swarm%20mode
Swarm mode refers to cluster management and orchestration features embedded in Docker Engine. When you initialize a new swarm (cluster) or join nodes to a swarm, the Docker Engine runs in swarm mode.
五、Docker Swarm
https://docs.docker.com/swarm/
You are viewing docs for legacy standalone Swarm. These topics describe standalone Docker Swarm. In Docker 1.12 and higher, Swarm mode is integrated with Docker Engine. Most users should use integrated Swarm mode — a good place to start is Getting started with swarm mode, Swarm mode CLI commands, and the Get started with Docker walkthrough). Standalone Docker Swarm is not integrated into the Docker Engine API and CLI commands.