Gauravpandey44 Docker-Swarm
Gauravpandey44 Docker-Swarm
Swarm is Docker’s in built containers orchestrator 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 SERVICE|TASK task, in option you can use -f,--d‐
anything to get started. etails etc
In Docker, there are many layers of encapsulation: the OS kernel, docker service ls list all the services
containers, tasks that encapsulate containers as units of work,
docker service ps [OPTIONS] List the tasks of one or more
services or Pods that represent application components, and stacks‐
SERVICE [SERVICE...] services
(collection of services) that represent full applications.
docker service rm SERVICE Remove one or more services
[SERVICE...]
docker swarm commands
docker service scale SERVIC‐ Scale one or multiple replicated
docker swarm init Initialize a swarm
E=REPLICAS [SERVICE=REP‐ services
docker swarm join --token<manager- Join an existing swarm as LICAS...]
token> 10.1.0.2:2377 manager node
docker service update Update a service
docker swarm join --token<worker-tok‐ Join a swarm as a worker [OPTIONS] SERVICE
en> 10.1.0.2:2377 node
Manage services.Services 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-compose file , docker node commands
deploy nodeapp Swarm does not support the build option if
docker node ls List nodes in the swarm
-c docker-com‐ defined in the Compose file(but docker compose
docker node ps List tasks running on one or more
pose.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-name>
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
<stack-name>
NODE [NODE...] manager in the swarm
docker stack rm removes the stack.
<stack-name>
cheatography.com/gauravpandey44/
Docker Swarm Cheat Sheet
by Gaurav Pandey (gauravpandey44) via cheatography.com/69622/cs/20590/
cheatography.com/gauravpandey44/