This document provides an introduction to Docker Swarm, which allows multiple Docker hosts to be clustered together into a single virtual Docker host. It discusses key components of Docker Swarm including managers, nodes, services, discovery services, and scheduling. It also provides steps for creating a Swarm cluster, deploying services, and considering high availability and security aspects.
5. Docker Swarm - Walid Ashraf
What is Swarm
Docker Swarm is native clustering for Docker.
• It turns a pool of Docker hosts into a single, virtual Docker host.
Docker Swarm serves the standard Docker API, any tool that already
communicates with a Docker daemon can use Swarm to transparently scale
to multiple hosts.
7. Docker Swarm - Walid Ashraf
Docker Discovery Service
A key Value store for configurations
Defaults to a hosted discovery service with Docker Swarm.
The service maintains a list of IPs in your cluster. This page describes the different types of hosted discovery available to you.
Discovery service replacements (Libkv abstraction):
• Consul
• Etcd
• ZooKeeper
Should be replicated
8. Docker Swarm - Walid Ashraf
Swarm Manager
It’s the cluster admin or master
All communications with nodes passes through it
Supports HA
• 1 Primary (the Actual Admin)
• Multiple Secondary Managers (Transfers to primary)
• In case of primary failure (leader election occurs)
9. Docker Swarm - Walid Ashraf
How this works
The Manager deploys the required services (Containers) to a host(s) based on the configurations.
The Manager checks with the discovery service for available nodes
The Client Issue a command to the swarm manager
10. Docker Swarm - Walid Ashraf
Filtering:
The ability to mask some of the nodes
Constraints
•node to refer to the node by ID or name
•storagedriver
•executiondriver
•kernelversion
•operatingsystem
Resources
•Containerslots Number of containers on a host
•Port
Containers
•Affinity filters
•container name or id
•an image on the host
•a custom label applied to the container
•Depencecy
11. Docker Swarm - Walid Ashraf
Scheduling
Random
Spread
• Default
• Least no of containers
• CPU and RAM aware
Binpack
• Most no of containers
• CPU and RAM aware
16. Docker Swarm - Walid Ashraf
What is a service
A service is a container in swarm mode.
Examples of services might include an HTTP server, a database, or any other type of
executable program that you wish to run in a distributed environment.
Things to be configured in a service
The port where the swarm will make the service available outside the swarm
An overlay network for the service to connect to other services in the swarm
CPU and memory limits and reservations
A rolling update policy
The number of replicas of the image to run in the swarm