0% found this document useful (0 votes)
4 views2 pages

Gauravpandey44 Docker-Swarm

Uploaded by

hasrule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Gauravpandey44 Docker-Swarm

Uploaded by

hasrule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Docker Swarm Cheat Sheet

by Gaurav Pandey (gauravpandey44) via cheatography.com/69622/cs/20590/

Basic docker service commands

Swarm is Docker’s in built containers orches​trator solution, its main docker service create --replicas create docker service directly
purpose is to manage containers in a computer cluster, i.e. a set of 5 -p 80:80 --name web nginx (similar to docker run command)
connected computers that work together. docker service logs [OPTIONS] Fetch the logs of a service or
Swarm comes built into the Docker Engine, you don’t need to install SERVIC​E|TASK task, in option you can use -f,--d​‐
anything to get started. etails etc
In Docker, there are many layers of encaps​ula​tion: the OS kernel, docker service ls list all the services
contai​ners, tasks that encaps​ulate containers as units of work,
docker service ps [OPTIONS] List the tasks of one or more
services or Pods that represent applic​ation compon​ents, and stacks​‐
SERVICE [SERVI​CE...] services
(co​lle​ction of services) that represent full applic​ations.
docker service rm SERVICE Remove one or more services
[SERVI​CE...]
docker swarm commands
docker service scale SERVIC​‐ Scale one or multiple replicated
docker swarm init Initialize a swarm
E=R​EPLICAS [SERVI​CE=​REP​‐ services
docker swarm join --toke​n<m​ana​ger​- Join an existing swarm as LIC​AS...]
to​ken> 10.1.0.2:2377 manager node
docker service update Update a service
docker swarm join --toke​n<w​ork​er-​tok​‐ Join a swarm as a worker [OPTIONS] SERVICE
en> 10.1.0.2:2377 node
Manage servic​es.S​er​vices in the swarm mode are actually object
docker swarm leave Leave the swarm
(when compared to the docker compose services where they are
actual running services)
docker stack commands

docker stack deploy the stack using docker​​-c​o​mpose file , docker node commands
deploy nodeapp Swarm does not support the build option if
docker node ls List nodes in the swarm
-c docker​​-c​o​m​‐ defined in the Compose file(but docker compose
docker node ps List tasks running on one or more
po​​se.yml up uses it).
nodes, defaults to current node
docker stack ls shows all stacks along with list of services in the
docker node rm Remove one or more nodes from the
stack
[OPTIONS] NODE swarm
docker stack list the services in the stack.
[NODE...]
services <st​‐
docker node demote Demote one or more nodes from
ack​-na​me>
NODE [NODE...] manager in the swarm
docker stack ps list all the tasks in the stack.
docker node promote Promote one or more nodes to
<st​ack​-na​me>
NODE [NODE...] manager in the swarm
docker stack rm removes the stack.
<st​ack​-na​me>

Manage Docker stacks( is a collection of services that make up an


applic​ation in a specific enviro​nment).

By Gaurav Pandey Published 22nd September, 2019. Sponsored by CrosswordCheats.com


(gauravpandey44) Last updated 22nd September, 2019. Learn to solve cryptic crosswords!
Page 1 of 2. http://crosswordcheats.com

cheatography.com/gauravpandey44/
Docker Swarm Cheat Sheet
by Gaurav Pandey (gauravpandey44) via cheatography.com/69622/cs/20590/

Common Terms/Key concepts Swarm service diagram

Node is a physical or virtual machine (running an instance of


the Docker Engine.)
Manager perform swarm management and orches​tration duties. By
nodes default manager nodes are also worker nodes.
Worker execute tasks.
nodes
Cluster one or more nodes grouped together.
Swarm is a type of cluster in docker termin​ology.
Docker (not part of docker engine)is a separate product which
Swarm you can use to cluster multiple Docker hosts. Prior to Applic​ation
Docker version 1.12 it was the only native Docker option
for clustering hosts, and it needed a lot of additional
setup for distri​buted state, service discovery and security.
Swarm With Docker 1.12,(is built into Docker Engine) To run a
Mode cluster you just need to install Docker on multiple
machines, run docker swarm init to switch to Swarm
Mode and docker swarm join to add more nodes to the
cluster. State, discovery and security are all included with
zero setup. similar commands
Stack is a collection of services that make up an applic​ation in a Init host as a swarm manager node :
specific enviro​nment. docker swarm init
service it defines the blueprint about which image to use and Deploy applic​ation:
which commands to execut​e,p​ort​s,n​etw​ork​s,r​epl​ica​s,etc docker stack deploy -c docker​-co​mpo​se.yml myApp
inside future running contai​ners. List services:
task in swarm model,task is actually invoked inside a contai​‐ docker service ls
ner.When service is created the swarm manager starts a docker stack services myApp
task(or its replicas) inside various contai​ners. List tasks:
docker service ps myApp_web
docker container ls -q
docker stack ps myApp
Stop applic​ation
:
docker stack rm myApp
Take down swarm
docker swarm leave --force

By Gaurav Pandey Published 22nd September, 2019. Sponsored by CrosswordCheats.com


(gauravpandey44) Last updated 22nd September, 2019. Learn to solve cryptic crosswords!
Page 2 of 2. http://crosswordcheats.com

cheatography.com/gauravpandey44/

You might also like