Docker Swarm and Creating Cluster on Docker

Initializing and Joining Swarm
Sudo docker swarm init

NOTE: if you have multiple network interfaces on the host (or on guest VM) , then you need to specify the "--advertise-addr" with specific ip

Worked fine after specifying the ip



From the second VM , run the following command to join as worker node in swarm



To list all swarm nodes connected to manager


NOTE: Only swarm managers execute Docker commands; workers are just for capacity.



For deploying applications (service)




To Change no of Replicas (nodes)
a.       Simple modify the docker compose file
b.       Re run the stack deploy command as shown
:/> docker stack deploy -c docker-compose.yml getstartedlab

To list the service which are running
:/> docker service ls

To list the nodes where the service is running
:/>docker service ps getstartedlab

To remove (uninstall) the service
:/> docker service rm getstartedlab



Leaving Swarm
Sudo docker swarm leave



NOTE: you may need to use the "--force" to leave the last manager from the swarm.

No comments:

Post a Comment