Pages

Friday, 15 July 2016

Docker Swarm Mode Basic


What is an Docker Swarm Mode?

docker is intruducing cluster management and orchestration feauture in v1.12. They already released beta versions with this feauture. Earlier thay had cluster management tool docker swarm but now they are including docker swarm into the docker engine it self which they are calling docker engine in swarm mode.
For more document please refer Docker engine swarm mode doc.

What is an Docker Swarm?

Its cluster of docker engine where you can deploy services. Service is nothing but your container template from this template we can create container and scale also.
For more document please refer Docker engine swarm mode doc.



Prerequisite

For our demo i am expecting following arrangment.
       1) Three VM’s or machines which should be reachable each other.
       2) Install Docker Engine 1.12 or later on each VM’s (You can install from Docker github installation guide)
       3) Open ports b/w the each VM’s
              a) 2377/tcp: Swarm Cluster management
              b) 7946/tcp-udp: for communication b/w nodes
              c) 4789/tcp-udp: for overlay network traffic

Basic Command For Docker Swarm Mode

       1) To create swarm manager :
          # docker swarm init --listen-addr {MANAGER-IP}:{PORT}

       2) To list swarm node :
          # docker node ls

       3) To join another node to swarm cluster :
          # docker swarm join {MANAGER-IP}:{PORT}

       4) To create service in swarm cluster :
          # docker service create --name nginx--replicas 1 nginx:1.10

       5) To inspect any service:
          # docker service inspect --pretty nginx #(Basic and important Info)
          # docker service inspect nginx #(Full Information in Json format)

      &nbsp6) To see which nodes are running service :
          # docker service tasks nginx

      &nbsp7) To Scale service in the swarm cluster :
          # docker service scale nginx=3
          # docker service update --replicas 3 nginx

      &nbsp8) To delete any service :
          # docker service remove nginx

      &nbsp9) To list services :
          # docker service ls

      &nbsp10) Update service with new version :
          # docker service update --image nginx:1.10.1 nginx

      &nbsp11) Put a swarm node in maintenance :
          # docker node update --availability drain swarm-worker1

Here is the demo of Docker Swarm Mode

                   

No comments:

Post a Comment