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

Docker Swarm

The document provides instructions for initializing and managing a Docker Swarm, including commands for adding managers and workers, creating and deleting services, and scaling containers. It also covers updating services with specific parameters and deploying stacks using YAML configuration files. Additionally, it includes commands for rolling back and visualizing the Docker Swarm setup.

Uploaded by

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

Docker Swarm

The document provides instructions for initializing and managing a Docker Swarm, including commands for adding managers and workers, creating and deleting services, and scaling containers. It also covers updating services with specific parameters and deploying stacks using YAML configuration files. Additionally, it includes commands for rolling back and visualizing the Docker Swarm setup.

Uploaded by

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

nodes :: managers → recommneded to be odd number (make service, delete service) ,,

worker →

***********************************************************************************
*************

#init docker swarm on master


docker swarm init --advertise-addr 192.168.1.10:2377 --listen-addr
192.168.1.10:2377

Swarm initialized: current node (s7gq2hvalvr53pu1r6oix7cfs) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join --token SWMTKN-1-


6ddv46schv5zsnyzauj9iclymx6ems2a0ys56ap4fhu7kf48ly-dga4t2b3lkgozv91ocxgj1mfh
192.168.1.10:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow
the instructions.

***********************************************************************************
****************

docker swarm join-token worker → get token for workers


docker swarm join-token managers → get token for managers

***********************************************************************************
****************

docker service create --name web -p 80:80 --replicas 5 nginx:latest → make a


service in docker swarm (in docker swarm we work with services not as containers)
docker service ls → list all services
docker service ps service-name → info about service
docker service rm service-name → delete service
docker service scale service-name=9 → scale to 9 containers

***********************************************************************************
****************

docker service update --image image-name --update-parallelism 2 --update-delay 10s


sevice-name
--update-delay 10s → wait 10s befor update next container
--update-parallelism 2 → update 2 by 2

***********************************************************************************
****************

docker stack deploy -c docker-stack.yaml stack-name → can be use for update all
stack , and we use this when deploy for first time
docker stack deploy -c ./Portainer/docker-stack.yaml stack-name2 → this comand to
run portainer

docker stack rollback stack-name → rollback

*Update services one by one*


docker service update --image adham00/dotnet-server:v1.1 backend
docker service update --image adham00/sql-server:v1.0 database
docker service update --image adham00/web-server:v1.1 frontend

***********************************************************************************
****************

docker service create --name=viz --publish=8080:8080/tcp --


constraint=node.role==manager
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock
dockersamples/visualizer

You might also like