有了新的功能强大、简单易用的Swarm mode集群,基本就不需要老的Docker Swarm主机集群了。两个概念一定要区分开!否则会给Docker中的 Swarm mode 的使用造成麻烦。不能把这两个概念混为一谈:使用Docker machine create 命令自带的--swarm --swarm-master参数创建了一个Docker Swarm 集群,却想使用只有Swarm mode 才支持的swarm、node、service 等子命令,肯定会报错。
老的Docker Swarm使用独立的外部KV存储(比如Consul、etcd、zookeeper),搭建独立运行的Docker主机集群,用户像操作单台Docker 机器一样操作整个集群,Docker Swarm把多台Docker主机当做一台Docker主机来管理。在docker 1.12版之前,只有搭建Docker Swarm集群,没有Swarm mode之说,结合machine和compose来操作所有Docker机器。这样的集群也是可以正常运行的,没有任何问题。
新的Swarm mode 是在docker 1.12版本中集成到 Docker 引擎中的,引入服务的概念,提供了众多的新特性,比如:具有容错能力的去中心化设计、内置服务发现、负载均衡、路由网格、动态伸缩、滚动更新、安全传输等。使得Docker 原生的Swarm mode集群具备与Mesos、Kubernetes叫板的实力。
参考链接及转载的内容:
1、Swarm、Swarmkit和Swarm模式傻傻分不清
http://www.linuxprobe.com/swarm-swarmkit.html
如果不熟悉的人该问了,这个和之前的Docker Swarm(在Docker 1.6时就有了)有什么不同么?之前的Swarm要弃用了么?不是前几天刚出个Swarmkit么?话说也是佩服Docker能把产品搞得这么复杂,弄出这么多名称,也真是让人醉了。
相信抱有此疑问的人不在少数。这里,我们就来简单看一下Docker Swarm(之前和Docker machine、Docker compose并称三剑客)、swarmkit和Swarm mode之间的区别。
Docker Swarm
独立于Docker engine
需要额外的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。
2、Swarm、SwarmKit、Swarm mode 对比
http://blog.csdn.net/halcyonbaby/article/details/52037091
3、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.
4、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.
5、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.