Docker Swarm
Docker swarm:
docker swarm init - This will start swarm service and the host in which ypu executed this command will become leader
- It will give some result and we need to paste that code in worker nodes and we ned to enable 2377 port for communication
docker swarm leave
- The node will come out of cluster
Docker service commands:
1.docker service create -p 80:80 --replicas=3 --name=web --niginx
If we don't specify any replicas by default 1 service will be created
2.docker service ls
It will list services
3.docker service ps web
List the tasks of one or more services, it will display information of service like on which workers how many instances are running and which is leader,reachable and worker etc, if we do docker inspect of taskID,we can see many more details
4.docker service scale web=3
we can scale or descale number of instances of service running by giving its number
5.docker service inspect web
This will give information about service, by default it will display data in json format,we can use format option to filter or --preety option to convert json format to yaml format
docker service inspect --pretty web
6.docker service rm web
It will remove service
7.docker service update --force web
updates the services with same number of replicas
Mnaging Node:
1.docker node ls
It will show the status of nodes in a cluster
2.docker node promote <ip or hostname>
it will promote node to reachable,so that if leader is down,then this machine has the capability to become leader
3.docker node demo <ip or hostname>
demote the leader or reachable machine o worker
4.docker node update --availabilty drain <node>
do not assign/create containers in this host,it is usually executed in leaders to rduce load on leader
5. docker node update --availability active <node>
if we want to bring back frained host to normal state,we use this
Comments
Post a Comment