EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

Docker Swarm Architecture

Home » Software Development » Software Development Tutorials » Docker Tutorial » Docker Swarm Architecture

Docker swarm architecture

Introduction to Docker Swarm Architecture

Docker Swarm is a clustering and Orchestration tool for Containers which is inbuilt in Docker Engine for the distributed system which involves hundreds of containers. Docker Node, Docker Services, and Docker tasks are key components of Docker swarm architecture.

  • Docker Node: It is the Docker Engine instance included in Docker swarm, has  two kinds:
  • Manager Node: Responsible for all orchestration and container management tasks required to maintain the system in the desired state such as maintaining the cluster state, scheduling the services and servicing the swarm mode HTTP endpoints.
  • Docker Service: It is the task definition that needs to be executed.

Typical Docker Swarm Architecture

Below are the points for typical docker swarm architecture:

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

  • Node is the key member of docker swarm architecture, a swarm architecture can have more than one manager nodes lead by a single manager node elected using the Raft algorithm, a manager node can also work as a worker node but can be configured to work as manager node too.
  • Manager nodes use the Raft Consensus Algorithm to internally manage the cluster state. This is to ensure that all manager nodes that are scheduling and controlling tasks in the cluster maintain/store consistent state.
  • A swarm is a cluster of Docker Engines or nodes, where we deploy our services. At the early stage, Docker came up with a cluster management system with a communication protocol known as Beam. Later on, they added more API’s and renamed it to swarm. The first generation swarm is called ‘swarm v1’.

Work Flow of Docker Swarm

The workflow of docker swarm consists of understanding how nodes and services work in a docker swarm architecture:

Step 1: The first step is to create a set of docker-machine that will act as nodes in the docker swarm, one among these nodes will be the manager, the remaining node\s will act as worker nodes. To create a docker-machine use the command on Windows, launch the docker terminal.

docker-machine create –driver hyperv manager1

  • Where ‘manager1’ is the docker-machine name, to list the machines and it’s run respectively.

docker-machine ls
docker-machine ip manager1

Step 2: The second step is to create worker machines, use below command to create as much as worker machines you want, here let’s create 3 workers.

docker-machine create –driver hyperv worker1
docker-machine create –driver hyperv worker2
docker-machine create –driver hyperv worker3

  • We can connect to the manager or worker using the below command, which will get you to inside the machine.

docker-machine ssh manager1/worker1

Step 3: Step three is to initialize the docker swarm, we have to run this command on the machine which we want work as a manager, that is how we make node manager, we can add more managers as well.

Popular Course in this category
Docker Training (4 Courses, 3 Projects)4 Online Courses | 3 Hands-on Projects | 11+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (4,456 ratings)
Course Price

View Course

Related Courses
Python Training Program (36 Courses, 13+ Projects)All in One Software Development Bundle (600+ Courses, 50+ projects)

docker-machine ssh manager1
docker swarm init –advertise-and Manager1 IP

Step 4: Step four is to join the worker nodes to swarm, get the command to join node as a worker using below command on manager machine and run the command you have got on the worker machine you want to make a worker.

Docker swarm join-token worker1

  • To check whether the worker is joined to swarm or not go to the manager machine and run command, it will list the added worker machine with manager details.

docker-machine ls

Step 5: Step five is to run the docker standard commands on the manager.

docker info (fetches details about docker swarm)
docker swarm (commands that can run on docker swarm such as join,leave,update,init and unlock etc)

Step 6: Step six is to run the docker containers on docker swarm, we can create any service and it’s replicas. Go to ub.docker.com, login and go to explore depositaries we can see different images which are engines, for example, nginx(it runs on webserver) creates a service and it’s replica’s using below command on the manager.

docker service create –replicas 3 -p 80:80 –name sample nginx

  • Where ‘sample’ is the service name and 80 is the port that is being exposed to check the status of the service run below command on the manager node.

docker service ls
docker service ps sample

Check the service running on all nodes and also check on the browser by giving IP for all nodes.

Step 7: Step seven, now we can see the actual use of docker swarm where we scale the service up and down. To scale a service run the below command on  manager machine

docker service scale sample=4

  • The above command will make the service sample to run on 4 nodes,  even though all nodes are busy it will create another service on manager or worker. Similar way we can scale down the service.

docker service scale sample=2

  • We can also inspect the node to get the details like how many and which service  are running on a node by running the below commands on the manager node

docker node inspect worker1/manager1
docker node inspect self

Step 8: Step eight is to update service when service is running on multiple machines and if we want to update the service it very is and simple, for example, if we want to update the version of the service nginx.

docker service update –image  nginx:1.14.0 sample

Step 9: Shutdown/stop/remove.

  • To shut down any particular node use the below command,  which changes the status of the node to ‘drain’.

docker node update –availability drain worker1

  • To remove service from all machines.

docker service rm sample

  • To leave the swarm, which changes the status of the ‘down’.

docker swarm  leave

  • To stop a machine (Run from docker terminal, not in manager or worker machine).

docker-machine stop worker1
docker-machine rm worker1

Benefits of Docker Swarm Architecture

Below are the points shows the benefits of Docker Swarm Architecture:

  1. Decentralized design: we can manage swarm clusters through swarm command, It gives single p[oint of access to build entire swarm.
  2. It is very simple compared to Kubernetes.
  3. High Availability: Among the nodes available in swarm if master fails another worker node will take upcharge.
  4. Desired state Reconciliation: The swarm manager keeps track of the cluster state so that the desired and actual state is always the same.
  5. When we specify an over network to connect to your services, the swarm manager assigns addresses to the container on overlay network once we create /update the containers
  6. Rolling Updates: Service updates can be done incrementally swarm manager allows you to specify the delay between every update without any downtime.

Conclusion

Docker swarm is a simple tool in place of big tools that accomplish the task, Docker with swarm provides orchestration that we need, it’s easy to set up and ships the native with docker engine which we are going to install and use anyway.

Recommended Articles

This is a guide to Docker Swarm Architecture. Here we discuss how nodes and services work in a docker swarm architecture with their benefits. You can also go through our other related articles to learn more –

  1. Docker Architecture
  2. What is Docker Swarm?
  3. Swarm Intelligence Applications
  4. Does Swarming Technology Helps Agile Teams to Grow?

Docker Training (4 Courses)

4 Online Courses

3 Hands-on Projects

11+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Docker Tutorial
  • Docker Swarm
    • What is Docker Swarm
    • Docker Swarm Architecture
  • Docker
    • What is Docker in Linux
    • Docker Architecture
    • Install Docker
    • Advantages of Docker
    • Docker Commands
    • Docker Toolbox
    • Docker Storage Drivers
    • Docker Push
    • Docker run Command
    • Dockerfile
    • Docker Container Linking
    • Docker Stop Container
    • Docker List Containers
    • Docker Registry
    • Docker Volume
    • Docker Export
    • Docker Import
    • Docker Systemd
    • Docker Stack
    • Docker Privileged
    • Docker Pull
    • Docker Start
    • Docker system prune
    • Docker Hosts
    • Docker Logging
    • Docker Save
    • Docker Commands Cheat Sheet
  • Interview Questions
    • Docker Interview Questions

Related Courses

Docker Training Course

Python Training Course

Software Development Course Training

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Docker Training (4 Courses) Learn More