SlideShare una empresa de Scribd logo
1 de 20
Docker Swarm
Author : Rajdeep Dua, VMware
Twitter : @rajdeepdua
Last Updated : March 25 2015
Overview
• Allows to manage Docker Cluster Remotely
• Key Components
– Swarm Manager
– Swarm Node
– Scheduler
– Discovery
Architecture Diagram
Swarm Manager
• Manages the Nodes in the Cluster
• Uses Docker APIs to access the Docker Daemon
running on each node
• Nodes are added to the Swarm manager by
callback from Discovery Service’s fetch() function
• Elements of a Swarm Cluster Manager
– Event Handler
– Map of Nodes
– Store
– Options
Swarm Node
• Runtime Instance representing a node in the Cluster.
• Talks to the actual Host using Docker Go Client
• Created from a DiscoveryEntry fetched from a Discovery Service
• Elements of Swarm Node
– Id
– IP Address (of remote host)
– Map of Containers
– Map of Images
– Health state of the node
– Total CPUs
– Used CPUs
– Total Memory
– Used Memory
Scheduler
• Responsible for scheduling a container on a
Node
• Pluggable architecture – Bring your own
scheduler
• Elements of a Scheduler
– Placement Strategy Instance
– Array of Filters
Scheduler .. contd
• The `Docker Swarm` scheduler comes with multiple strategies.
• These strategies are used to rank nodes using a scores
computed by the strategy. `Docker Swarm` currently supports
2 strategies:
– BinPacking Strategy
– Random Strategy
Usage : You can choose the strategy you want to use with the `--
strategy` flag of `swarm manage`
Scheduler .. contd
BinPacking strategy
• The BinPacking strategy will rank the nodes using their CPU and RAM
available and will return the node the most packed already.
• This avoid fragmentation, it will leave room for bigger containers on
unused machines.
Random strategy
• The Random strategy, as it's name says, chooses a random node, it's used
mainly for debug
Scheduler Filters
• Scheduler uses the following filters for container
placement on a node
– Affinity Filter
– Constraint Filter : When creating a container, the user
can select a subset of nodes that should be
considered for scheduling by specifying one or more
sets of matching key/value pairs.
– Port Filter : Select node where public port required by
the container is not already used
– Health Filter : Select only healthy nodes from the
cluster
Swarm Store
• Stores the state of the Cluster.
• Currently implemented as a JSON file
• State is loaded in memory when the cluster starts
• Lifecycle events of the store
– Get state for a key
– Store the state of a container
– Load all the data stored
– Replace the state of the key with a new state
– Delete the state
Discovery Service
• Helps Swarm Manager discover nodes
• Three main functions
– Register : Registers a new node
– Watch : Callback method for Swarm Manager
when a new Node is added to the Discovery
Service
– Fetch : Fetch the List of Entries
Discovery Services
• Token Based
• etcd based
• Zookeeper based
• File Based
• Consul Based
• Bring your own?
Docker Swarm Architecture - Exploded
Token Based Discovery Service
• Based on REST End Point hosted on Docker-
hub
• URL Queried for entries is
DISCOVERY_URL = "https://discovery-stage.hub.docker.com/v1"
HTTP GET https://discovery-stage.hub.docker.com/v1/clusters/<token-id>
Discovery Fetch Entries
Swarm CLI
• Allows Setting up and Managing the Cluster
create a cluster
$ docker run --rm swarm create
6856663cdefdec325839a4b7e1de38e8
On each nodes, start the swarm agent
$ docker run -d swarm join --addr=<node_ip:2375> token://<cluster_id>
Swarm CLI
Start the manager on any machine / Laptop to manage the
cluster
$ docker run -d -p <swarm_port>:2375 swarm manage token://<cluster_id>
Use the regular docker cli
$ docker -H tcp://<swarm_ip:swarm_port> info
$ docker -H tcp://<swarm_ip:swarm_port> run ...
$ docker -H tcp://<swarm_ip:swarm_port> ps
$ docker -H tcp://<swarm_ip:swarm_port> logs ...
…
List nodes in your cluster
$ docker run --rm swarm list token://<cluster_id>
<node_ip:2375>
Swarm APIs
• Compatible with Docker Remote API with
some differences
• Containers
GET /containers/(id)
POST /containers/create
DELETE /containers/(id)
POST /container/(id)/start
additional parameters passed in the POST body
Swarm APIs…
Images
GET /images/json
POST /images/create
DELETE /images/(id)
GET /images/search
Summary
• Docker Swarm allows you to use native Docker
CLI commands and APIs to manage containers
across a cluster of nodes
• It has a basic scheduler which can be
enhanced
• Pluggable Discovery mechanism

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Dockers and kubernetes
Dockers and kubernetesDockers and kubernetes
Dockers and kubernetes
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
A Hands-On Introduction To Docker Containers.pdf
A Hands-On Introduction To Docker Containers.pdfA Hands-On Introduction To Docker Containers.pdf
A Hands-On Introduction To Docker Containers.pdf
 
Intro to containerization
Intro to containerizationIntro to containerization
Intro to containerization
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Docker and the Linux Kernel
Docker and the Linux KernelDocker and the Linux Kernel
Docker and the Linux Kernel
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker in real life
Docker in real lifeDocker in real life
Docker in real life
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 

Destacado

Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
NGINX, Inc.
 

Destacado (20)

Docker Swarm: Docker Native Clustering
Docker Swarm: Docker Native ClusteringDocker Swarm: Docker Native Clustering
Docker Swarm: Docker Native Clustering
 
Docker Online Meetup #28: Production-Ready Docker Swarm
Docker Online Meetup #28: Production-Ready Docker SwarmDocker Online Meetup #28: Production-Ready Docker Swarm
Docker Online Meetup #28: Production-Ready Docker Swarm
 
Introction to docker swarm
Introction to docker swarmIntroction to docker swarm
Introction to docker swarm
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introduction
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster management
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Docker, Docker Swarm mangement tool - Gorae
Docker, Docker Swarm mangement tool - GoraeDocker, Docker Swarm mangement tool - Gorae
Docker, Docker Swarm mangement tool - Gorae
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarm
 
Docker Networking & Swarm Mode Introduction
Docker Networking & Swarm Mode IntroductionDocker Networking & Swarm Mode Introduction
Docker Networking & Swarm Mode Introduction
 
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) ItalyClustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep Dive
 
Docker Networking: Control plane and Data plane
Docker Networking: Control plane and Data planeDocker Networking: Control plane and Data plane
Docker Networking: Control plane and Data plane
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
 
Docker Machine & Docker Swarm
Docker Machine & Docker SwarmDocker Machine & Docker Swarm
Docker Machine & Docker Swarm
 
Kubernetes Mesos Architecture
Kubernetes Mesos ArchitectureKubernetes Mesos Architecture
Kubernetes Mesos Architecture
 
docker-machine, docker-compose, docker-swarm 覚書
docker-machine, docker-compose, docker-swarm 覚書docker-machine, docker-compose, docker-swarm 覚書
docker-machine, docker-compose, docker-swarm 覚書
 

Similar a Docker Swarm Introduction

Similar a Docker Swarm Introduction (20)

Introducing Docker Swarm - the orchestration tool by Docker
Introducing Docker Swarm - the orchestration tool by DockerIntroducing Docker Swarm - the orchestration tool by Docker
Introducing Docker Swarm - the orchestration tool by Docker
 
DockerCon SF 2015: Orchestration for Sysadmins
DockerCon SF 2015: Orchestration for SysadminsDockerCon SF 2015: Orchestration for Sysadmins
DockerCon SF 2015: Orchestration for Sysadmins
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
Dockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarmDockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarm
 
Containers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. KubernetesContainers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. Kubernetes
 
Alex Dias: how to build a docker monitoring solution
Alex Dias: how to build a docker monitoring solution Alex Dias: how to build a docker monitoring solution
Alex Dias: how to build a docker monitoring solution
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scale
 
What’s new in Swarm 1.1
What’s new in Swarm 1.1What’s new in Swarm 1.1
What’s new in Swarm 1.1
 
PostgreSQL and Linux Containers
PostgreSQL and Linux ContainersPostgreSQL and Linux Containers
PostgreSQL and Linux Containers
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
 DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and... DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
 
Postgre sql linuxcontainers by Jignesh Shah
Postgre sql linuxcontainers by Jignesh ShahPostgre sql linuxcontainers by Jignesh Shah
Postgre sql linuxcontainers by Jignesh Shah
 
AstriCon 2017 - Docker Swarm & Asterisk
AstriCon 2017  - Docker Swarm & AsteriskAstriCon 2017  - Docker Swarm & Asterisk
AstriCon 2017 - Docker Swarm & Asterisk
 
Monitoring and Log Management for
Monitoring and Log Management forMonitoring and Log Management for
Monitoring and Log Management for
 
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
 
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
 
Kubernetes Walk Through from Technical View
Kubernetes Walk Through from Technical ViewKubernetes Walk Through from Technical View
Kubernetes Walk Through from Technical View
 
SFBay Area Solr Meetup - June 18th: Benchmarking Solr Performance
SFBay Area Solr Meetup - June 18th: Benchmarking Solr PerformanceSFBay Area Solr Meetup - June 18th: Benchmarking Solr Performance
SFBay Area Solr Meetup - June 18th: Benchmarking Solr Performance
 
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
 
Demystfying container-networking
Demystfying container-networkingDemystfying container-networking
Demystfying container-networking
 

Más de rajdeep

Openstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overviewOpenstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overview
rajdeep
 
Cloud Foundry Architecture and Overview
Cloud Foundry Architecture and OverviewCloud Foundry Architecture and Overview
Cloud Foundry Architecture and Overview
rajdeep
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platform
rajdeep
 

Más de rajdeep (15)

Aura Framework Overview
Aura Framework OverviewAura Framework Overview
Aura Framework Overview
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5
 
Openstack Overview
Openstack OverviewOpenstack Overview
Openstack Overview
 
virtualization-vs-containerization-paas
virtualization-vs-containerization-paasvirtualization-vs-containerization-paas
virtualization-vs-containerization-paas
 
VMware Hybrid Cloud Service - Overview
VMware Hybrid Cloud Service - OverviewVMware Hybrid Cloud Service - Overview
VMware Hybrid Cloud Service - Overview
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Dive
 
Openstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overviewOpenstack meetup-pune-aug22-overview
Openstack meetup-pune-aug22-overview
 
Deploy Cloud Foundry using bosh_bootstrap
Deploy Cloud Foundry using bosh_bootstrapDeploy Cloud Foundry using bosh_bootstrap
Deploy Cloud Foundry using bosh_bootstrap
 
Managing Activity Backstack
Managing Activity BackstackManaging Activity Backstack
Managing Activity Backstack
 
Cloud Foundry Architecture and Overview
Cloud Foundry Architecture and OverviewCloud Foundry Architecture and Overview
Cloud Foundry Architecture and Overview
 
Cloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , KeynoteCloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , Keynote
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platform
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

Docker Swarm Introduction

  • 1. Docker Swarm Author : Rajdeep Dua, VMware Twitter : @rajdeepdua Last Updated : March 25 2015
  • 2. Overview • Allows to manage Docker Cluster Remotely • Key Components – Swarm Manager – Swarm Node – Scheduler – Discovery
  • 4. Swarm Manager • Manages the Nodes in the Cluster • Uses Docker APIs to access the Docker Daemon running on each node • Nodes are added to the Swarm manager by callback from Discovery Service’s fetch() function • Elements of a Swarm Cluster Manager – Event Handler – Map of Nodes – Store – Options
  • 5. Swarm Node • Runtime Instance representing a node in the Cluster. • Talks to the actual Host using Docker Go Client • Created from a DiscoveryEntry fetched from a Discovery Service • Elements of Swarm Node – Id – IP Address (of remote host) – Map of Containers – Map of Images – Health state of the node – Total CPUs – Used CPUs – Total Memory – Used Memory
  • 6. Scheduler • Responsible for scheduling a container on a Node • Pluggable architecture – Bring your own scheduler • Elements of a Scheduler – Placement Strategy Instance – Array of Filters
  • 7. Scheduler .. contd • The `Docker Swarm` scheduler comes with multiple strategies. • These strategies are used to rank nodes using a scores computed by the strategy. `Docker Swarm` currently supports 2 strategies: – BinPacking Strategy – Random Strategy Usage : You can choose the strategy you want to use with the `-- strategy` flag of `swarm manage`
  • 8. Scheduler .. contd BinPacking strategy • The BinPacking strategy will rank the nodes using their CPU and RAM available and will return the node the most packed already. • This avoid fragmentation, it will leave room for bigger containers on unused machines. Random strategy • The Random strategy, as it's name says, chooses a random node, it's used mainly for debug
  • 9. Scheduler Filters • Scheduler uses the following filters for container placement on a node – Affinity Filter – Constraint Filter : When creating a container, the user can select a subset of nodes that should be considered for scheduling by specifying one or more sets of matching key/value pairs. – Port Filter : Select node where public port required by the container is not already used – Health Filter : Select only healthy nodes from the cluster
  • 10. Swarm Store • Stores the state of the Cluster. • Currently implemented as a JSON file • State is loaded in memory when the cluster starts • Lifecycle events of the store – Get state for a key – Store the state of a container – Load all the data stored – Replace the state of the key with a new state – Delete the state
  • 11. Discovery Service • Helps Swarm Manager discover nodes • Three main functions – Register : Registers a new node – Watch : Callback method for Swarm Manager when a new Node is added to the Discovery Service – Fetch : Fetch the List of Entries
  • 12. Discovery Services • Token Based • etcd based • Zookeeper based • File Based • Consul Based • Bring your own?
  • 14. Token Based Discovery Service • Based on REST End Point hosted on Docker- hub • URL Queried for entries is DISCOVERY_URL = "https://discovery-stage.hub.docker.com/v1" HTTP GET https://discovery-stage.hub.docker.com/v1/clusters/<token-id>
  • 16. Swarm CLI • Allows Setting up and Managing the Cluster create a cluster $ docker run --rm swarm create 6856663cdefdec325839a4b7e1de38e8 On each nodes, start the swarm agent $ docker run -d swarm join --addr=<node_ip:2375> token://<cluster_id>
  • 17. Swarm CLI Start the manager on any machine / Laptop to manage the cluster $ docker run -d -p <swarm_port>:2375 swarm manage token://<cluster_id> Use the regular docker cli $ docker -H tcp://<swarm_ip:swarm_port> info $ docker -H tcp://<swarm_ip:swarm_port> run ... $ docker -H tcp://<swarm_ip:swarm_port> ps $ docker -H tcp://<swarm_ip:swarm_port> logs ... … List nodes in your cluster $ docker run --rm swarm list token://<cluster_id> <node_ip:2375>
  • 18. Swarm APIs • Compatible with Docker Remote API with some differences • Containers GET /containers/(id) POST /containers/create DELETE /containers/(id) POST /container/(id)/start additional parameters passed in the POST body
  • 19. Swarm APIs… Images GET /images/json POST /images/create DELETE /images/(id) GET /images/search
  • 20. Summary • Docker Swarm allows you to use native Docker CLI commands and APIs to manage containers across a cluster of nodes • It has a basic scheduler which can be enhanced • Pluggable Discovery mechanism