Docker Swarm:
Docker swarm is a container orchestration clustering tool in
simple manages multiple containers that running on the group of the docker host
Benefits of running containers in docker in the swarm mode
àHigh availability of services
àLoad balancing
àScaling the containers
àRolling updates
Swarm Architecture:
àOne node will be acting as a Manager
Node can add any no of nodes but primary task manages the cluster
àworker node will run actual load
àcontainers will be running in form of services
Creating the docker swarm cluster
àgoing to create a cluster of 3 nodes
one is manager, worker1 and worker2 in docker swarm can create any no of
manager nodes and any no of worker nodes
àIf you want to add a node as a
manager by the command before that you can start docker on all the nodes
Docker swarm init --advertise-addr ipAddress --it acts as a manager it will start the
cluster to add workers to this swarm
It gives the command like token
Docker swarm join \
--token swatkljsjkas
-1-2ashhjkashkalkslksajlkjklasjkljsakfasf \
10.142.2.1:2377
àthis command will run on other nodes
it will become worker nodes if you want to retrieve back to the command it
means to add worker nodes type docker swarm join-token worker it will
give the command use this command as any node to become a worker node
àdocker node ls --it
shows the list of clusters and its status
àIf you want to become a any node as a
manager to run this docker swarm join-token manager it gives the command
and it run on node to become a manager
Creating containers in docker swarm cluster:
àcreating container in docker swarm in
the form of service by the following command
Docker service create -p 8001:80 --name websvc nginx --it
starts the container from the image nginx and it exposes a port on 8001 and it can
access the service on all the worker nodes and manager node also because all
are in the same cluster, they are open for
àdocker service ls --to
see the service is running or not
àdocker ps webservice(serviceName) --it shows the details and where it is running if the load
is running on the manager node you can change the load into the worker node by
draining the manager node by the command
àdocker node update --availability
drain manager to
drain no-load take the manager node
àdocker service ps webservice --to show the service running on the worker node you go to
that worker node and give the command docker ps it will show the service
running get the ip address followed by the port mapping it will show the
service on any of the nodes it may be worker node or manager node because that
port is open any for cluster-wide
àIf you want to do the maintenance of
worker 1 it will shut down or drain worker 1 the services are running on the
worker 1 is shifted into worker 2 nodes by achieving the High availability
of the service
Secalling up the service:
àdocker service scale webservice=10 --it
means it increase the resources to 10 to show docker service ls and see where
it is running by the docker service ps webservice to show the whare it
is running
No comments:
Post a Comment