DOCKER 2

SAIRAM MANDAPAKA
3 min readJan 19, 2021

--

A swarm is a group of machines that are running on docker and joined into a cluster, Docker swarm is a tool for a container that manages and controls multiple docker containers as a single service.

create a docker swarm and deploy API services in a cluster using a script.

  1. Install the docker-machine and When you click on the docker icon when it is running, you will come across a set of options like a sign-in option with your Id. Go through that and sign in.
  2. After signing in with your own docker id, then go to the command prompt and check the version which you installed.
  3. Create Docker machines (to act as nodes for Docker Swarm) Create one machine as manager and others as workers By using the commands docker-machine create — driver HyperV manager1 docker-machine create — driver VirtualBox manager.
  4. Create one manager machine and other worker machines.
  5. Check machine created successfully by using the commands docker-machine ls docker-machine ip manager1.
  6. SSH (connect) to docker-machine using command docker-machine ssh manager1.
  7. Initialize Docker Swarm docker using swarm init — advertise-addr MANAGER_IP docker node ls (this command will work only in swarm manager and not in worker).
  8. Join workers in the swarm Get command for joining as worker In manager node run command docker swarm join-token worker This will give the command to join the swarm as worker docker swarm join-token manager This will give the command to join the swarm as manager SSH into worker node (machine) and run command to join the swarm as worker In Manager Run command — docker node ls to verify worker is registered and is ready Do this for all worker machines.
  9. On manager run standard docker commands docker info check the swarm section no of manager, nodes, etc
  10. Now check docker swarm command options docker swarm.
  11. Run containers on Docker Swarm docker service create — replicas 3 -p 80:80 — name serviceName nginx Check the status: docker service ls docker service ps serviceName Check the service running on all nodes Check on the browser by giving IP for all nodes.
  12. Scale service up and down On manager node docker service scale serviceName=2 Inspecting Nodes (this command can run only on manager node) docker node inspect nodename docker node inspect self docker node inspect worker1
  13. Shutdown node docker node update — availability drain worker1
  14. Update service docker service update — imageimage name: version web docker service update — image nginx:1.14.0 serviceName
  15. Remove service docker service rm serviceName docker swarm leave: to leave the swarm docker-machine stop machine name: to stop the machine docker-machine rm machine name: to remove the machine.

service discovery, high availability, and microservices

Microservices architecture refers us to a number of small microservices talking to each other, one of the important things about microservices architecture is a feature called auto-scaling.

Service discovery is how applications and (micro)services locate each other on a network. Service discovery implementations include bothi.e a central server (or servers) that maintain a global view of addresses and clients that connect to the central server to update and retrieve addresses.

High availability is termed as the availability of a machine or a service containing fault tolerance and disaster recovery, High availability comes in the scenario where the service is expecting downtime or the application which is being used by the users containing high latency so in order to avoid all these conditions high availability comes in the scenario to low the latency and by providing low downtime to the users using the application.

High availability gives us the ipact of saving the application in case of a server failure or a server crash by achieving the fault tolerance and disaster recovery.

--

--

SAIRAM MANDAPAKA
SAIRAM MANDAPAKA

Written by SAIRAM MANDAPAKA

0 Followers

Cloud Engineer

No responses yet