Swarm Mode: Built-In Orchestration
- Swarm Mode is a clustering solution built inside Docker
- Not related to Swarm "classic" for pre-1.12 versions
- Added in 1.12 (Summer 2016) via SwarmKit toolkit
- Enhanced in 1.13 (January 2017) via Stacks and Secrets
- Not enabled by default, new commands once enabled:
- docker swarm
- docker node
- docker service
- docker stack
- docker secret
Containers Everywhere = New Problems
These were the questions people asked before swarm mode
- How do we automate container lifecycle?
- How can we easily scale out/in/up/down?
- How can we ensure our containers are re-created if they fail?
- How can we replace containers without downtime (blue/green deploy)?
- How can w control/track where containers get started?
- How can we create cross-node virtual networks?
- How can we ensure only trusted servers run our containers?
- How can we store secrets, keys, passwords and get them to the right container (and only that container)?
Basic Concepts
- Swarm can be enabled with
docker swarm init
Manager Nodes
- These blue boxes are
manager nodes
- Have database locally on them (known as Raft database)
- It stores their configuration and gives them all information they need need to have to be the authority inside the swarm
- Encrypt their traffic
- Docker recommends a maximum of seven manager nodes for a swarm.
- Have database locally on them (known as Raft database)
Worker Nodes
Worker nodes are also instances of Docker Engine whose sole purpose is to execute containers. Worker nodes don’t participate in the Raft distributed state, make scheduling decisions, or serve the swarm mode HTTP API.
- You can create a swarm of one manager node, but you cannot have a worker node without at least one manager node
- By default, all managers are also workers.
Manager nodes are basically a worker nodes with permission to manage the swarm.
docker container run
command always only can deploy a one container.- With this concept of a Swarm and these managers we now have new concepts of what our containers looks like.
Swarm Service
docker service
in a swarm replacesdocker container run
command