SlideShare a Scribd company logo
Docker Swarm
Introduction
Evan Lin @Linker Networks
About Me
● Cloud Architect @ Linker
Networks
● Top 10 Taiwan Golang open
source contributor (github
award)
● Developer, Curator, Blogger
Agenda
● Docker Swarm
● Docker SwarmKit
● Introduction Docker Swarm Mode (Swarm
V2)
● Docker Swarm Mode Features
● Docker Swarm Mode Tutorial
● Q&A
Original Docker
Management multiple docker between
machines
Let’s use Docker Swarm (Tranditional)
Let’s use Docker Swarm (Tranditional)
Architecture
Let’s use Docker Swarm (Tranditional)
Steps
Setup Docker Swarm
● Startup a K/V value server (Consul) keystore
● Create a swarm manager
● Connect swarm manager to the keystore
● Create multiple swarm workers
● Connect swarm worker to keystore
● Swarm worker join to swarm manager
Load balancer ?
● Create a load balancer ...
Step 1:
Startup Keystore
● Create A docker-Machine
○ docker-machine create -d virtualbox
--virtualbox-memory "2000"
--engine-opt="label=com.function=consul"
keystore
● Sync to keystore machine
○ eval $(docker-machine env keystore)
● Run “consul” a K/V server container
○ docker run --restart=unless-stopped -d -p
8500:8500 -h consul progrium/consul
-server -bootstrap
Step 2:
Startup Swarm Manager
● Create docker-machine for swarm manager
○ docker-machine create -d virtualbox
--virtualbox-memory "2000"
--engine-opt="label=com.function=manage
r"
--engine-opt="cluster-store=consul://$(doc
ker-machine ip keystore):8500"
--engine-opt="cluster-advertise=eth1:2376"
manager
● Sync to swarm manager machine
○ eval $(docker-machine env manager)
Step 2:
Startup Swarm Manager
● Start docker swarm
container
○ docker run --restart=unless-stopped -d -p 3376:2375 -v
/var/lib/boot2docker:/certs:ro swarm manage --tlsverify
--tlscacert=/certs/ca.pem --tlscert=/certs/server.pem
--tlskey=/certs/server-key.pem consul://$(docker-machine ip
keystore):8500
Step 3~6:
Startup Swarm Manager
● Start docker swarm worker
○ docker-machine create -d virtualbox --virtualbox-memory "2000"
--engine-opt="label=com.function=frontend01"
--engine-opt="cluster-store=consul://$(docker-machine ip
keystore):8500" --engine-opt="cluster-advertise=eth1:2376"
frontend01
● Sync to fronted01
○ eval $(docker-machine env frontend01)
● Join to Swarm Manager
○ docker run -d swarm join --addr=$(docker-machine ip
frontend01):2376 consul://$(docker-machine ip keystore):8500
Step 7:
Startup Load Balancer
● Start docker swarm worker
○ docker-machine create -d virtualbox --virtualbox-memory "2000"
--engine-opt="label=com.function=interlock" loadbalancer
● Download “Interlock” and setup
○ git clone https://github.com/ehazlett/interlock.git
○ cd config
○ Fill with `config.toml` ...
● Run Load Balancer “Interlock”
○ docker run -P -d -ti -v nginx:/etc/conf -v
/var/lib/boot2docker:/var/lib/boot2docker:ro -v
/var/run/docker.sock:/var/run/docker.sock -v
$(pwd)/config.toml:/etc/config.toml --name interlock
ehazlett/interlock:1.0.1 -D run -c /etc/config.toml
I can do this “ALL DAY”
SwarmKit
Different with Docker Swarm
● Where is “Consul” ?
○ The K/V DB already built-in in
Swarm Kit
● More security communication.
○ It default support TLS
● What is Raft Consensus ?
○ For data consistentcy and election
node if master is down.
SwarmKit
Master
● Build SwarmKit binaries
○ git clone
https://github.com/docker/swarmkit.git
○ cd swarmkit
○ make setup
○ make all
● Run Swarm manager
○ swarmd -d /tmp/node-1
--listen-control-api
/tmp/manager1/swarm.sock
--hostname node-1
SwarmKit
Master
● Sync swarm socket
○ export
SWARM_SOCKET=/tmp/manager1/
swarm.sock
● Check Swarm master
○ swarmctl cluster inspect default
SwarmKit
Agent
● Run Swarm Agent (worker)
○ swarmd -d /tmp/node-2 --hostname node-2
--join-addr 127.0.0.1:4242 --join-token
SWMTKN-1-1wttj6u10f9fueptptma9ohf99zcxt0gia1
wt3a5odphi6nt1f-c4y428p7wwr23efwo4xw6qiwz
○ swarmd -d /tmp/node-3 --hostname node-3
--join-addr 127.0.0.1:4242 --join-token
SWMTKN-1-1wttj6u10f9fueptptma9ohf99zcxt0gia1
wt3a5odphi6nt1f-c4y428p7wwr23efwo4xw6qiwz
● Check node status
○ swarmctl node ls
Complete SwarmKit setup
SwarmKit
Create A Service
● Create a Swarm Kit service
○ swarmctl service create --name redis
--image redis:3.0.5
● Make sure service status
○ swarmctl node ls
SwarmKit
Create A Service
● Create a Swarm Kit service
○ swarmctl service create --name redis
--image redis:3.0.5
● Make sure service status
○ swarmctl service ls
● Check detail of service
○ swarmctl service inspect redis
SwarmKit
Scale Your Service
● Scale Swarm Kit service
○ swarmctl service update redis
--replicas 6
● Make sure service status
○ swarmctl service ls
○ swarmctl service ls
SwarmKit
Scale Your Service
● Inspect service detail
○ swarmctl service inspect redis
SwarmKit
Update Service
● Update service directly
○ swarmctl service update redis
--image redis:3.0.6
Docker swarm introduction
SwarmKit
Rolling Update
● Update two services every 10 seconds
○ swarmctl service update redis
--image redis:3.0.7
--update-parallelism 2
--update-delay 10s
SwarmKit
Drain Node
● Stop node 1
○ swarmctl node drain node-1
Docker swarm introduction
● Docker Swarm Mode ( Swarm
version 2)
● New feature from Docker Engine
1.12
● Powerful and more security
Docker Swarm Mode
Different between
Docker Swarm, SwarmKit and Swarm V2
Docker Swarm SwarmKit Swarm Mode (v2)
Docker Version All All >= 1.12
K/V DB Need extra one Built-In Built-In
Extra Binaries No
Yes
(Use Go 1.6)
No
Security None Built-In Built-In
Extra Service None None
Routing Mesh
Load Balance
Support Docker
Compose,
Docker-Machine
Yes Yes
No
(for now)
Docker swarm introduction
Docker Swarm Mode Tutorial - Vote App
Docker Swarm Mode:
● Create three docker machine
○ docker-machine create --driver
virtualbox v1
○ docker-machine create --driver
virtualbox v2
○ docker-machine create --driver
virtualbox v3
V1
192.168.99.100
V2
192.168.99.101
V3
192.168.99.102
Docker Swarm Mode:
● Connect to V1 node
○ docker-machine ssh v1
○ ifconfig
● Init docker swarm manager
○ docker swarm init --listen-addr
192.168.99.100:2377
--advertise-addr 192.168.99.100
V1
192.168.99.100
V2
192.168.99.101
V3
192.168.99.102
Docker Swarm Mode:
● Connect to V2, V3 node
○ docker-machine ssh v2
○ docker-machine ssh v3
● Init docker swarm worker
○ docker swarm join --token
SWMTKN-1-62q9gzw8uc43fbv7n79
h7lsnmc6j2tqpzb4qy2osurxufxz87u-
97v5wplu0dvit5ssveo5da2h6
192.168.99.100:2377
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
Docker Swarm Mode:
● Check current node status
○ docker-machine ssh v1
○ docker node ls
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
Docker Swarm Mode: All setup is
done
Docker Swarm Mode:
● Connect to Swarm Manager create
service “vote”
○ docker-machine ssh v1
○ docker service create --name vote -p
8080:80 instavote/vote
● Check detail of this service
○ docker service ls
● Check which node run this service
○ docker service ps vote
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote
Docker swarm introduction
Docker swarm introduction
Docker Swarm Mode:
● Scale “vote” service to 3
○ docker service scale vote=2
● Check detail of this service
○ docker service ls
● Check which node run this service
○ docker service ps vote
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote
instavote/
vote
Random
Load Balacncer
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote
instavote/
vote
Client
LB
Docker Swarm Mode:
● Scale “vote” service from 2 to 3
○ docker service scale vote=3
● Check detail of this service
○ docker service ls
● Check which node run this service
○ docker service ps vote
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote
instavote/
vote
instavote/
vote
Docker Swarm Mode:
● Service update (Immediately)
○ docker service update --image
instavote/vote:movies vote
● Check detail of this service
○ docker service ls
● Check which node run this service
○ docker service ps vote
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote:
movies
instavote/
vote:
movies
instavote/
vote:
movies
Docker Swarm Mode:
● Service update (Rolling Update)
○ docker service update vote --image
instavote/vote:indent
--update-parallelism 1
--update-delay 10s
● Check detail of this service
○ docker service ls
● Check which node run this service
○ docker service ps vote
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote:
indent
instavote/
vote:
indent
instavote/
vote:
indent
Docker Swarm Mode:
● Global Services
○ docker service create --mode=global --name prometheus
prom/prometheus
● Check detail of this service
○ docker service ls
● Check which node run this service
○ docker service ps prometheus
V1
(Manager)
192.168.99.100
V2
(Worker)
192.168.99.101
V3
(Worker)
192.168.99.102
instavote/
vote:
indent
instavote/
vote:
indent
instavote/
vote:
indent
prometheus
prometheus
prometheus
Different between Docker Swarm, SwarmKit
and Swarm V2
Docker Swarm SwarmKit Swarm Mode (v2)
Docker Version All All >= 1.12
K/V DB Need extra one Built-In Built-In
Extra Binaries No
Yes
(Use Go 1.6)
No
Security None Built-In Built-In
Extra Service None None
Routing Mesh
Load Balance
Support Docker
Compose,
Docker-Machine
Yes Yes
No
(for now)
Q&A

More Related Content

PDF
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
PDF
Introduction to Docker Compose
PDF
Introduction to Docker storage, volume and image
PPTX
Docker Swarm for Beginner
PPT
presentation on Docker
PDF
PDF
Introduction to container based virtualization with docker
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Introduction to Docker Compose
Introduction to Docker storage, volume and image
Docker Swarm for Beginner
presentation on Docker
Introduction to container based virtualization with docker

What's hot (20)

PPTX
Docker 101 - Nov 2016
PPTX
Docker Swarm Introduction
PPTX
Docker introduction
PPTX
Introduction to Docker - 2017
PDF
Docker-PPT.pdf for presentation and other
PPTX
Introduction to docker
PPTX
Docker Basics
PPTX
Docker: From Zero to Hero
PDF
Intro To Docker
PDF
PDF
Docker Swarm 0.2.0
PDF
Dockerfile
PDF
Kubernetes Basics
PPTX
Kubernetes Introduction
PDF
Alphorm.com Formation Docker (1/2) : Installation et Administration
PDF
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
PDF
Introduction to docker
PPTX
Intro to docker
PDF
Docker Introduction
PPTX
Docker introduction & benefits
Docker 101 - Nov 2016
Docker Swarm Introduction
Docker introduction
Introduction to Docker - 2017
Docker-PPT.pdf for presentation and other
Introduction to docker
Docker Basics
Docker: From Zero to Hero
Intro To Docker
Docker Swarm 0.2.0
Dockerfile
Kubernetes Basics
Kubernetes Introduction
Alphorm.com Formation Docker (1/2) : Installation et Administration
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Introduction to docker
Intro to docker
Docker Introduction
Docker introduction & benefits
Ad

Viewers also liked (20)

PDF
Modern Web 2016: Using Golang to build a smart IM Bot
DOCX
Advanced ETL2 Pentaho
PPTX
Elementos ETL - Kettle Pentaho
PDF
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
PPTX
Scaling Jenkins with Docker and Kubernetes
PDF
Jenkins Peru Meetup Docker Ecosystem
PDF
Pentaho | Data Integration & Report designer
PDF
Tao zhang
PDF
Migración de datos con OpenERP-Kettle
PDF
Docker Ecosystem: Engine, Compose, Machine, Swarm, Registry
PPTX
Introduction to docker swarm
PPTX
Docker Ecosystem - Part II - Compose
PPTX
NGINX Plus PLATFORM For Flawless Application Delivery
PPTX
Building Data Integration and Transformations using Pentaho
PPTX
Continuous Development with Jenkins - Stephen Connolly at PuppetCamp Dublin '12
PPSX
Business Intelligence and Big Data Analytics with Pentaho
PDF
Introduction to GPU Programming
PDF
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
PPTX
Indic threads pune12-accelerating computation in html 5
PDF
Building a data warehouse with Pentaho and Docker
Modern Web 2016: Using Golang to build a smart IM Bot
Advanced ETL2 Pentaho
Elementos ETL - Kettle Pentaho
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Scaling Jenkins with Docker and Kubernetes
Jenkins Peru Meetup Docker Ecosystem
Pentaho | Data Integration & Report designer
Tao zhang
Migración de datos con OpenERP-Kettle
Docker Ecosystem: Engine, Compose, Machine, Swarm, Registry
Introduction to docker swarm
Docker Ecosystem - Part II - Compose
NGINX Plus PLATFORM For Flawless Application Delivery
Building Data Integration and Transformations using Pentaho
Continuous Development with Jenkins - Stephen Connolly at PuppetCamp Dublin '12
Business Intelligence and Big Data Analytics with Pentaho
Introduction to GPU Programming
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Indic threads pune12-accelerating computation in html 5
Building a data warehouse with Pentaho and Docker
Ad

Similar to Docker swarm introduction (20)

PDF
Swarm: Native Docker Clustering
PPTX
Docker-machine
PDF
Docker 1.12 and swarm mode
PDF
Clustering Docker with Docker Swarm on openSUSE
PDF
OSDC 2019 | Evolution of a Microservice-Infrastructure by Jan Martens
PDF
Docker HK Meetup - 201707
PPTX
Docker cluster with swarm, consul, registrator and consul-template
PDF
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
PDF
What’s new in Swarm 1.1
 
PDF
Docker 進階實務班
PDF
廣宣學堂: 容器進階實務 - Docker進深研究班
PDF
Swarm mode
PDF
Introduction to Docker and Monitoring with InfluxData
PDF
Scala, docker and testing, oh my! mario camou
PDF
Docker Essentials Workshop— Innovation Labs July 2020
PDF
DockerCon EU '17 - Dockerizing Aurea
PDF
Perspectives on Docker
PDF
Making kubernetes simple for developers
PDF
Building Bizweb Microservices with Docker
PDF
DCEU 18: Building Your Development Pipeline
Swarm: Native Docker Clustering
Docker-machine
Docker 1.12 and swarm mode
Clustering Docker with Docker Swarm on openSUSE
OSDC 2019 | Evolution of a Microservice-Infrastructure by Jan Martens
Docker HK Meetup - 201707
Docker cluster with swarm, consul, registrator and consul-template
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What’s new in Swarm 1.1
 
Docker 進階實務班
廣宣學堂: 容器進階實務 - Docker進深研究班
Swarm mode
Introduction to Docker and Monitoring with InfluxData
Scala, docker and testing, oh my! mario camou
Docker Essentials Workshop— Innovation Labs July 2020
DockerCon EU '17 - Dockerizing Aurea
Perspectives on Docker
Making kubernetes simple for developers
Building Bizweb Microservices with Docker
DCEU 18: Building Your Development Pipeline

More from Evan Lin (20)

PDF
好書分享: 一人公司 Company Of One
PDF
How to master a programming language: a Golang example"
PDF
Golang taipei #45 10th birthday
PPTX
How I become Go GDE
PDF
iThome Modern Web 2018: 如何打造高效的機器學習平台
PPTX
Kubernetes secret introduction
PDF
Consistent hashing algorithmic tradeoffs
PDF
GTG30: Introduction vgo
PDF
Kubernetes v.s. mesos
PDF
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
PDF
iThome Cloud Summit: The next generation of data center: Machine Intelligent ...
PDF
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
PDF
Google APAC Machine Learning Expert Day
PDF
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
PDF
Use go channel to write a disk queue
PDF
Gopher Taiwan Gathering #16: Build a smart bot via Golang
PDF
COSCUP 2016: Project 52 每週一個小專案來學習 Golang
PDF
Docker introduction in Hardware Company
PDF
Host Line Bot with Golang
PDF
Project52
好書分享: 一人公司 Company Of One
How to master a programming language: a Golang example"
Golang taipei #45 10th birthday
How I become Go GDE
iThome Modern Web 2018: 如何打造高效的機器學習平台
Kubernetes secret introduction
Consistent hashing algorithmic tradeoffs
GTG30: Introduction vgo
Kubernetes v.s. mesos
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
iThome Cloud Summit: The next generation of data center: Machine Intelligent ...
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
Google APAC Machine Learning Expert Day
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
Use go channel to write a disk queue
Gopher Taiwan Gathering #16: Build a smart bot via Golang
COSCUP 2016: Project 52 每週一個小專案來學習 Golang
Docker introduction in Hardware Company
Host Line Bot with Golang
Project52

Recently uploaded (20)

PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
Behind the Smile Unmasking Ken Childs and the Quiet Trail of Deceit Left in H...
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
“Google Algorithm Updates in 2025 Guide”
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
artificial intelligence overview of it and more
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
QR Codes Qr codecodecodecodecocodedecodecode
PPT
tcp ip networks nd ip layering assotred slides
PDF
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
Digital Literacy And Online Safety on internet
SAP Ariba Sourcing PPT for learning material
Introuction about WHO-FIC in ICD-10.pptx
Behind the Smile Unmasking Ken Childs and the Quiet Trail of Deceit Left in H...
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
“Google Algorithm Updates in 2025 Guide”
PptxGenJS_Demo_Chart_20250317130215833.pptx
artificial intelligence overview of it and more
Tenda Login Guide: Access Your Router in 5 Easy Steps
Module 1 - Cyber Law and Ethics 101.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
introduction about ICD -10 & ICD-11 ppt.pptx
QR Codes Qr codecodecodecodecocodedecodecode
tcp ip networks nd ip layering assotred slides
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
WebRTC in SignalWire - troubleshooting media negotiation
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
international classification of diseases ICD-10 review PPT.pptx
The Internet -By the Numbers, Sri Lanka Edition
Digital Literacy And Online Safety on internet

Docker swarm introduction

  • 2. About Me ● Cloud Architect @ Linker Networks ● Top 10 Taiwan Golang open source contributor (github award) ● Developer, Curator, Blogger
  • 3. Agenda ● Docker Swarm ● Docker SwarmKit ● Introduction Docker Swarm Mode (Swarm V2) ● Docker Swarm Mode Features ● Docker Swarm Mode Tutorial ● Q&A
  • 5. Management multiple docker between machines
  • 6. Let’s use Docker Swarm (Tranditional)
  • 7. Let’s use Docker Swarm (Tranditional) Architecture
  • 8. Let’s use Docker Swarm (Tranditional) Steps Setup Docker Swarm ● Startup a K/V value server (Consul) keystore ● Create a swarm manager ● Connect swarm manager to the keystore ● Create multiple swarm workers ● Connect swarm worker to keystore ● Swarm worker join to swarm manager Load balancer ? ● Create a load balancer ...
  • 9. Step 1: Startup Keystore ● Create A docker-Machine ○ docker-machine create -d virtualbox --virtualbox-memory "2000" --engine-opt="label=com.function=consul" keystore ● Sync to keystore machine ○ eval $(docker-machine env keystore) ● Run “consul” a K/V server container ○ docker run --restart=unless-stopped -d -p 8500:8500 -h consul progrium/consul -server -bootstrap
  • 10. Step 2: Startup Swarm Manager ● Create docker-machine for swarm manager ○ docker-machine create -d virtualbox --virtualbox-memory "2000" --engine-opt="label=com.function=manage r" --engine-opt="cluster-store=consul://$(doc ker-machine ip keystore):8500" --engine-opt="cluster-advertise=eth1:2376" manager ● Sync to swarm manager machine ○ eval $(docker-machine env manager)
  • 11. Step 2: Startup Swarm Manager ● Start docker swarm container ○ docker run --restart=unless-stopped -d -p 3376:2375 -v /var/lib/boot2docker:/certs:ro swarm manage --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/server.pem --tlskey=/certs/server-key.pem consul://$(docker-machine ip keystore):8500
  • 12. Step 3~6: Startup Swarm Manager ● Start docker swarm worker ○ docker-machine create -d virtualbox --virtualbox-memory "2000" --engine-opt="label=com.function=frontend01" --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" --engine-opt="cluster-advertise=eth1:2376" frontend01 ● Sync to fronted01 ○ eval $(docker-machine env frontend01) ● Join to Swarm Manager ○ docker run -d swarm join --addr=$(docker-machine ip frontend01):2376 consul://$(docker-machine ip keystore):8500
  • 13. Step 7: Startup Load Balancer ● Start docker swarm worker ○ docker-machine create -d virtualbox --virtualbox-memory "2000" --engine-opt="label=com.function=interlock" loadbalancer ● Download “Interlock” and setup ○ git clone https://github.com/ehazlett/interlock.git ○ cd config ○ Fill with `config.toml` ... ● Run Load Balancer “Interlock” ○ docker run -P -d -ti -v nginx:/etc/conf -v /var/lib/boot2docker:/var/lib/boot2docker:ro -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/config.toml:/etc/config.toml --name interlock ehazlett/interlock:1.0.1 -D run -c /etc/config.toml
  • 14. I can do this “ALL DAY”
  • 16. Different with Docker Swarm ● Where is “Consul” ? ○ The K/V DB already built-in in Swarm Kit ● More security communication. ○ It default support TLS ● What is Raft Consensus ? ○ For data consistentcy and election node if master is down.
  • 17. SwarmKit Master ● Build SwarmKit binaries ○ git clone https://github.com/docker/swarmkit.git ○ cd swarmkit ○ make setup ○ make all ● Run Swarm manager ○ swarmd -d /tmp/node-1 --listen-control-api /tmp/manager1/swarm.sock --hostname node-1
  • 18. SwarmKit Master ● Sync swarm socket ○ export SWARM_SOCKET=/tmp/manager1/ swarm.sock ● Check Swarm master ○ swarmctl cluster inspect default
  • 19. SwarmKit Agent ● Run Swarm Agent (worker) ○ swarmd -d /tmp/node-2 --hostname node-2 --join-addr 127.0.0.1:4242 --join-token SWMTKN-1-1wttj6u10f9fueptptma9ohf99zcxt0gia1 wt3a5odphi6nt1f-c4y428p7wwr23efwo4xw6qiwz ○ swarmd -d /tmp/node-3 --hostname node-3 --join-addr 127.0.0.1:4242 --join-token SWMTKN-1-1wttj6u10f9fueptptma9ohf99zcxt0gia1 wt3a5odphi6nt1f-c4y428p7wwr23efwo4xw6qiwz ● Check node status ○ swarmctl node ls
  • 21. SwarmKit Create A Service ● Create a Swarm Kit service ○ swarmctl service create --name redis --image redis:3.0.5 ● Make sure service status ○ swarmctl node ls
  • 22. SwarmKit Create A Service ● Create a Swarm Kit service ○ swarmctl service create --name redis --image redis:3.0.5 ● Make sure service status ○ swarmctl service ls ● Check detail of service ○ swarmctl service inspect redis
  • 23. SwarmKit Scale Your Service ● Scale Swarm Kit service ○ swarmctl service update redis --replicas 6 ● Make sure service status ○ swarmctl service ls ○ swarmctl service ls
  • 24. SwarmKit Scale Your Service ● Inspect service detail ○ swarmctl service inspect redis
  • 25. SwarmKit Update Service ● Update service directly ○ swarmctl service update redis --image redis:3.0.6
  • 27. SwarmKit Rolling Update ● Update two services every 10 seconds ○ swarmctl service update redis --image redis:3.0.7 --update-parallelism 2 --update-delay 10s
  • 28. SwarmKit Drain Node ● Stop node 1 ○ swarmctl node drain node-1
  • 30. ● Docker Swarm Mode ( Swarm version 2) ● New feature from Docker Engine 1.12 ● Powerful and more security Docker Swarm Mode
  • 31. Different between Docker Swarm, SwarmKit and Swarm V2 Docker Swarm SwarmKit Swarm Mode (v2) Docker Version All All >= 1.12 K/V DB Need extra one Built-In Built-In Extra Binaries No Yes (Use Go 1.6) No Security None Built-In Built-In Extra Service None None Routing Mesh Load Balance Support Docker Compose, Docker-Machine Yes Yes No (for now)
  • 33. Docker Swarm Mode Tutorial - Vote App
  • 34. Docker Swarm Mode: ● Create three docker machine ○ docker-machine create --driver virtualbox v1 ○ docker-machine create --driver virtualbox v2 ○ docker-machine create --driver virtualbox v3 V1 192.168.99.100 V2 192.168.99.101 V3 192.168.99.102
  • 35. Docker Swarm Mode: ● Connect to V1 node ○ docker-machine ssh v1 ○ ifconfig ● Init docker swarm manager ○ docker swarm init --listen-addr 192.168.99.100:2377 --advertise-addr 192.168.99.100 V1 192.168.99.100 V2 192.168.99.101 V3 192.168.99.102
  • 36. Docker Swarm Mode: ● Connect to V2, V3 node ○ docker-machine ssh v2 ○ docker-machine ssh v3 ● Init docker swarm worker ○ docker swarm join --token SWMTKN-1-62q9gzw8uc43fbv7n79 h7lsnmc6j2tqpzb4qy2osurxufxz87u- 97v5wplu0dvit5ssveo5da2h6 192.168.99.100:2377 V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102
  • 37. Docker Swarm Mode: ● Check current node status ○ docker-machine ssh v1 ○ docker node ls V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102
  • 38. Docker Swarm Mode: All setup is done
  • 39. Docker Swarm Mode: ● Connect to Swarm Manager create service “vote” ○ docker-machine ssh v1 ○ docker service create --name vote -p 8080:80 instavote/vote ● Check detail of this service ○ docker service ls ● Check which node run this service ○ docker service ps vote V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102 instavote/ vote
  • 42. Docker Swarm Mode: ● Scale “vote” service to 3 ○ docker service scale vote=2 ● Check detail of this service ○ docker service ls ● Check which node run this service ○ docker service ps vote V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102 instavote/ vote instavote/ vote Random
  • 44. Docker Swarm Mode: ● Scale “vote” service from 2 to 3 ○ docker service scale vote=3 ● Check detail of this service ○ docker service ls ● Check which node run this service ○ docker service ps vote V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102 instavote/ vote instavote/ vote instavote/ vote
  • 45. Docker Swarm Mode: ● Service update (Immediately) ○ docker service update --image instavote/vote:movies vote ● Check detail of this service ○ docker service ls ● Check which node run this service ○ docker service ps vote V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102 instavote/ vote: movies instavote/ vote: movies instavote/ vote: movies
  • 46. Docker Swarm Mode: ● Service update (Rolling Update) ○ docker service update vote --image instavote/vote:indent --update-parallelism 1 --update-delay 10s ● Check detail of this service ○ docker service ls ● Check which node run this service ○ docker service ps vote V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102 instavote/ vote: indent instavote/ vote: indent instavote/ vote: indent
  • 47. Docker Swarm Mode: ● Global Services ○ docker service create --mode=global --name prometheus prom/prometheus ● Check detail of this service ○ docker service ls ● Check which node run this service ○ docker service ps prometheus V1 (Manager) 192.168.99.100 V2 (Worker) 192.168.99.101 V3 (Worker) 192.168.99.102 instavote/ vote: indent instavote/ vote: indent instavote/ vote: indent prometheus prometheus prometheus
  • 48. Different between Docker Swarm, SwarmKit and Swarm V2 Docker Swarm SwarmKit Swarm Mode (v2) Docker Version All All >= 1.12 K/V DB Need extra one Built-In Built-In Extra Binaries No Yes (Use Go 1.6) No Security None Built-In Built-In Extra Service None None Routing Mesh Load Balance Support Docker Compose, Docker-Machine Yes Yes No (for now)
  • 49. Q&A