Create swarm
docker swarm init --advertise-addr <MANAGER-IP>
-> copy command from here to join from nodes. e.g.:
docker swarm join --token SWMTKN-1-5fs8k04yvhalpcok7xa8ktryuin55w4gt1wf1aaj9vawwh52hx-1uk9i6yz3q7j7bzuqdun2xqwy 192.168.1.226:2377
docker swarm join-token manager
Stats / Info
docker node ls
docker service ls
docker service inspect service1
docker node ps node1 node2 node3
Manage nodes
from manager:
docker node promote node1
docker node demote node1
docker node rm node1
docker node inspect node1
docker node inspect --pretty node1
docker node update --role manager node1
docker node update --availability drain node1 # pause node and move load to other nodes
docker node update --availability active node1 # unpause and send back to work
from node:
docker swarm leave
Services
docker service create --replicas 4 --name service1 alpine ping google.com
docker service ls # list services
docker service ps service1 # list instances of service on nodes
docker service logs service1 -f
docker service scale service1=0
docker service rm service1
docker service update --image alpine service1