SlideShare a Scribd company logo
Docker Swarm Mode
Dharmit Shah
@dharm1t
Who am I?
● Software Engineer @ Red Hat; developing developer tools
● Co-organizer of Docker and Ansible meetups
● Work on CentOS, Docker, Ansible, Vagrant, etc.
● Love vim, zsh, i3wm, and all things CLI
● dharmit on GitHub
dharm1t on Twitter
What is Swarm Mode?
● A mode built into Docker Engine
● Available with Docker 1.12 or later
● Lets you manage a cluster of Docker Engines
● Cluster of Docker Engines is called a swarm
● Use the familiar Docker CLI to create a swarm, deploy
application services to a swarm, and manage swarm
behavior.
● Swarm Mode != Swarm Kit
Features
● Cluster management integrated with Docker Engine
● Can deploy Manager/Worker node using Docker Engine
● Declarative model to describe entire application stack
● Scale up or down based on requirements
● Constantly monitors and reconciles the cluster state
● Built in service discovery
● TLS auth and encryption for secure communication
Hands-on
My Setup
● 2 VMs running on DigitalOcean
● 1 will run as manager
● 1 will run as worker
● Add 1 VM to work as manager
Initialize a Swarm
$ docker swarm init
● This command will initialize a swarm
● Docker Engine targeted by this command becomes a manager
in the newly created single-node swarm
● Generates two random tokens - manager and worker tokens
● Use proper token to make a node join as worker or manager
Add a node to Swarm
$ docker swarm join 
--token <random-token-generated-by-previous-command> 
<ip-port-of-manager>
This command will add a node to a Swarm as worker node
$ docker swarm join-token manager
This command will add a manager node to Swarm
Create services
$ docker service create --name redis redis:3.0.6
Creates a service named redis
$ docker service create --name redis --replicas=5
redis:3.0.6
Creates a service redis with 5 replicas across the swarm
$ docker service ls
Lists the services in the cluster
Replicated mode & Global mode
$ docker service create --name redis --replicas=5 redis:3.0.6
Creates a service redis with 5 replicas across the swarm
$ docker service create --name redis --mode global redis:3.0.6
Creates a global service with 1 container on each node
Attach service to network
$ docker network create --driver overlay my-network
$ docker service create 
--replicas 3 --network my-network --name my-web 
nginx
$ docker service ls
Containers on the same network can access each other using
service discovery
Publish Service Ports
$ docker service create --name my_web --replicas 3 --publish
8080:80 nginx
Makes service accessible on port 8080 of every node
regardless if there is a container running for that service
on the node!
Swarm Inspect
$ docker service inspect nginx
● Provides JSON output
● Same as docker inspect for containers
● Should be run only on manager nodes
Swarm Update
● Update an existing service
$ docker service update --publish-add 6379:6379 redis
Publishes redis service to port 6379 on all nodes in Swarm
$ docker service update --image redis:latest redis
Let’s watch the output of “$ docker service ps redis”
Has many, many more options! Refer the docs.
Scale a service
$ docker service create --name redis redis:3.0.6
Creates a single container on a random node in the Swarm
$ docker service scale redis=2
Starts another container on a random node
ps, ls, rm,
● ps
○ List the tasks of a service
● ls
○ Lists the services in the swarm
● rm
○ Removes a service from the swarm
References
● https://docs.docker.com
● Slideshare by Mike Goelzer and Andrea Luzzardi
● Docker Community Repo
● And some tinkering with containers…
Thank you!

More Related Content

PDF
swarmmode-dojo
PDF
Docker 1.12 and swarm mode
PPTX
Docker Networking & Swarm Mode Introduction
PDF
Docker swarm introduction
PPTX
Docker Swarm for Beginner
PDF
The age of orchestration: from Docker basics to cluster management
PDF
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
PDF
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
swarmmode-dojo
Docker 1.12 and swarm mode
Docker Networking & Swarm Mode Introduction
Docker swarm introduction
Docker Swarm for Beginner
The age of orchestration: from Docker basics to cluster management
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy

What's hot (20)

PPTX
Docker Swarm Introduction
PDF
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
PPTX
Swarm - A Docker Clustering System
PPTX
Introduction to docker swarm
PDF
Going Production with Docker and Swarm
PDF
PDF
Docker Swarm 0.2.0
PDF
Consul and docker swarm cluster
PDF
What's New in Docker 1.12?
PDF
Docker Swarm & Machine
PPTX
Load Balancing Apps in Docker Swarm with NGINX
PPTX
Container Orchestration with Docker Swarm
PPTX
Docker Machine & Docker Swarm
PDF
Docker Swarm 45-min Workshop (Mountain View Docker Meetup 2/24/2016)
PDF
Docker Online Meetup #28: Production-Ready Docker Swarm
PDF
Dockercon Swarm Updated
PPTX
Docker cluster with swarm, consul, registrator and consul-template
PDF
Docker 1.12 & Swarm Mode [Montreal Docker Meetup Sept. 2016]
PDF
Docker swarm reloaded
PDF
Service Discovery & Load-Balancing under Docker 1.12.0 @ Docker Meetup #22
Docker Swarm Introduction
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
Swarm - A Docker Clustering System
Introduction to docker swarm
Going Production with Docker and Swarm
Docker Swarm 0.2.0
Consul and docker swarm cluster
What's New in Docker 1.12?
Docker Swarm & Machine
Load Balancing Apps in Docker Swarm with NGINX
Container Orchestration with Docker Swarm
Docker Machine & Docker Swarm
Docker Swarm 45-min Workshop (Mountain View Docker Meetup 2/24/2016)
Docker Online Meetup #28: Production-Ready Docker Swarm
Dockercon Swarm Updated
Docker cluster with swarm, consul, registrator and consul-template
Docker 1.12 & Swarm Mode [Montreal Docker Meetup Sept. 2016]
Docker swarm reloaded
Service Discovery & Load-Balancing under Docker 1.12.0 @ Docker Meetup #22
Ad

Viewers also liked (8)

PDF
Docker hands-on
PDF
Методы машинного обучения в физике элементарных частиц
PPTX
Azure container service overview
PDF
Kubernetes Mesos Architecture
PDF
Docker 1.12 - Swarm Mode
PDF
Docker Orchestrators
PDF
2017-03-11 01 Игорь Родионов. Docker swarm vs Kubernetes
PDF
Deploying and Scaling Microservices
Docker hands-on
Методы машинного обучения в физике элементарных частиц
Azure container service overview
Kubernetes Mesos Architecture
Docker 1.12 - Swarm Mode
Docker Orchestrators
2017-03-11 01 Игорь Родионов. Docker swarm vs Kubernetes
Deploying and Scaling Microservices
Ad

Similar to Swarm mode (20)

PDF
New Docker Features for Orchestration and Containers
PPTX
Academy PRO: Docker. Lecture 3
PDF
Docker HK Meetup - 201707
PDF
Deep Dive into Docker Swarm Mode
PPTX
Docker for the new Era: Introducing Docker,its components and tools
PPTX
Nats meetup oct 2016 docker 112
PDF
JDO 2019: Container orchestration with Docker Swarm - Jakub Hajek
PDF
AstriCon 2017 - Docker Swarm & Asterisk
PPTX
Introducing Docker Swarm - the orchestration tool by Docker
PDF
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
PDF
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
PDF
Dockertaipei 20150528-dockerswarm
PDF
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
PDF
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
PDF
Clustering Docker with Docker Swarm on openSUSE
PDF
PPTX
Docker Basic to Advance
PDF
Orchestrating Linux Containers while tolerating failures
PPTX
Docker session IV: Docker Compose and Docker Swarm
PDF
Docker 1.12 and SwarmKit
New Docker Features for Orchestration and Containers
Academy PRO: Docker. Lecture 3
Docker HK Meetup - 201707
Deep Dive into Docker Swarm Mode
Docker for the new Era: Introducing Docker,its components and tools
Nats meetup oct 2016 docker 112
JDO 2019: Container orchestration with Docker Swarm - Jakub Hajek
AstriCon 2017 - Docker Swarm & Asterisk
Introducing Docker Swarm - the orchestration tool by Docker
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Dockertaipei 20150528-dockerswarm
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Clustering Docker with Docker Swarm on openSUSE
Docker Basic to Advance
Orchestrating Linux Containers while tolerating failures
Docker session IV: Docker Compose and Docker Swarm
Docker 1.12 and SwarmKit

More from Dharmit Shah (12)

PDF
Introducing CentOS container pipeline
PDF
Introduction to Kubernetes
PDF
Introduction to Containers
PDF
Git push to build, test and scan your containers
PDF
Python in Industry
PPTX
Ansible in CI
PPTX
Introduction to ansible
PDF
Kubernetes
PDF
Atomic Developer Bundle
PDF
Docker tips & tricks
PPTX
Introducing docker
PDF
Rest apis with DRF
Introducing CentOS container pipeline
Introduction to Kubernetes
Introduction to Containers
Git push to build, test and scan your containers
Python in Industry
Ansible in CI
Introduction to ansible
Kubernetes
Atomic Developer Bundle
Docker tips & tricks
Introducing docker
Rest apis with DRF

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PDF
Modernizing your data center with Dell and AMD
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
A Presentation on Artificial Intelligence
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Modernizing your data center with Dell and AMD
Understanding_Digital_Forensics_Presentation.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
A Presentation on Artificial Intelligence
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication

Swarm mode

  • 2. Who am I? ● Software Engineer @ Red Hat; developing developer tools ● Co-organizer of Docker and Ansible meetups ● Work on CentOS, Docker, Ansible, Vagrant, etc. ● Love vim, zsh, i3wm, and all things CLI ● dharmit on GitHub dharm1t on Twitter
  • 3. What is Swarm Mode? ● A mode built into Docker Engine ● Available with Docker 1.12 or later ● Lets you manage a cluster of Docker Engines ● Cluster of Docker Engines is called a swarm ● Use the familiar Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior. ● Swarm Mode != Swarm Kit
  • 4. Features ● Cluster management integrated with Docker Engine ● Can deploy Manager/Worker node using Docker Engine ● Declarative model to describe entire application stack ● Scale up or down based on requirements ● Constantly monitors and reconciles the cluster state ● Built in service discovery ● TLS auth and encryption for secure communication
  • 6. My Setup ● 2 VMs running on DigitalOcean ● 1 will run as manager ● 1 will run as worker ● Add 1 VM to work as manager
  • 7. Initialize a Swarm $ docker swarm init ● This command will initialize a swarm ● Docker Engine targeted by this command becomes a manager in the newly created single-node swarm ● Generates two random tokens - manager and worker tokens ● Use proper token to make a node join as worker or manager
  • 8. Add a node to Swarm $ docker swarm join --token <random-token-generated-by-previous-command> <ip-port-of-manager> This command will add a node to a Swarm as worker node $ docker swarm join-token manager This command will add a manager node to Swarm
  • 9. Create services $ docker service create --name redis redis:3.0.6 Creates a service named redis $ docker service create --name redis --replicas=5 redis:3.0.6 Creates a service redis with 5 replicas across the swarm $ docker service ls Lists the services in the cluster
  • 10. Replicated mode & Global mode $ docker service create --name redis --replicas=5 redis:3.0.6 Creates a service redis with 5 replicas across the swarm $ docker service create --name redis --mode global redis:3.0.6 Creates a global service with 1 container on each node
  • 11. Attach service to network $ docker network create --driver overlay my-network $ docker service create --replicas 3 --network my-network --name my-web nginx $ docker service ls Containers on the same network can access each other using service discovery
  • 12. Publish Service Ports $ docker service create --name my_web --replicas 3 --publish 8080:80 nginx Makes service accessible on port 8080 of every node regardless if there is a container running for that service on the node!
  • 13. Swarm Inspect $ docker service inspect nginx ● Provides JSON output ● Same as docker inspect for containers ● Should be run only on manager nodes
  • 14. Swarm Update ● Update an existing service $ docker service update --publish-add 6379:6379 redis Publishes redis service to port 6379 on all nodes in Swarm $ docker service update --image redis:latest redis Let’s watch the output of “$ docker service ps redis” Has many, many more options! Refer the docs.
  • 15. Scale a service $ docker service create --name redis redis:3.0.6 Creates a single container on a random node in the Swarm $ docker service scale redis=2 Starts another container on a random node
  • 16. ps, ls, rm, ● ps ○ List the tasks of a service ● ls ○ Lists the services in the swarm ● rm ○ Removes a service from the swarm
  • 17. References ● https://docs.docker.com ● Slideshare by Mike Goelzer and Andrea Luzzardi ● Docker Community Repo ● And some tinkering with containers…