Docker swarm architecture LEARNOVITA

Docker Swarm Architecture | Everything You Need to Know [ OverView ]

Last updated on 03rd Nov 2022, Artciles, Blog

About author

Smita Jhingran (Big Data Engineer )

Smita Jhingran provides in-depth presentations on various big data technologies. She specializes in Docker, Hadoop, Microservices, MiNiFi, Cloudera, Commvault, and BI tools with 5+ years of experience.

(5.0) | 19547 Ratings 2123
    • In this article you will get
    • Docker Swarm architecture and components
    • Docker Swarm Workflow
    • Advantages of Docker Swarm architecture
    • Conclusion

Docker Swarm architecture and components

The main components of docker swarm architecture include a Docker tasks, Docker services, and Docker node.

Docker Node: Included in a docker swarm, this one is docker engine instance that is further divided into the two different types:

1.Manager Node: Manager nodes are basically liable for all of container management and an orchestration tasks needed to regulate the system in the specific state, like servicing the swarm mode of HTTP endpoints, scheduling of services, and maintaining a state of the cluster.

2.Docker Service: This one is referred to as a task definition which must be an executed.

Representative docker swarm architecture

To understand the typical docker swarm architecture, jotted down below are some of key points that make it an simple -to-understand concept:

  • For a docker swarm architecture, a node is the primary member.
  • It is possible for a swarm architecture to have the multiple manager nodes controlled by a one manager node that is elected with help of Raft algorithm.
  • Although a capable of working in a form of a worker node; however, a manager node cannot be configured or altered to work as a both manager and worker node at a same time.
  • To manage and regulate a state of the cluster internally, a manager node uses a Raft Consensus Algorithm. This is to make sure that all of manager nodes that have been scheduled to the control tasks in the cluster are stored or keep in a consistent situation.
  • A swarm is referred to a cluster of nodes or docker engines where services are can be deployed.
  • Initially, docker came with the system of cluster management with specific communication protocol called a Beam.
  • Later, more an APIs were added and renamed as swarm. Thus, a first-generation swarm is known as a swarm v1.
Docker architecture

Docker Swarm Workflow

The docker swarm workflow comprises understanding of how services and nodes work in a docker swarm architecture. Here is a step-by-step explanation to the comprehend the workflow in the better way.

Step 1:

The first and foremost step will be to develop the docker-machine set that will be acting as a nodes in the docker swarm. Among these, one is going to be a manager, and the rest will be a worker nodes. In order to create a docker-machine, below mentioned command is used on a Windows, and then docker terminal is be launched.

  • docker-machine create –driver hyperv manager1
  • Here, ‘manager1’ is a name of the docker-machine that lists machines as well as their run.
  • docker-machine ls
  • docker-machine ip manager1

Step 2:

The next step will be creation of a worker machines. Here are 3 different commands to create a varying worker machines.

  • docker-machine create –driver abcd worker1
  • docker-machine create –driver abcd worker2
  • docker-machine create –driver abcd worker3
  • Using a below command, the manager or worker can be connected to get inside machine.
  • docker-machine ssh manager1/worker1

Step 3:

The next step is to an initialize Docker swarm. On machine that should be worked as manager, this command should be run to make node manager.

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

Step 4:

The fourth step helps to join a worker nodes to swarm. This can easily be done by using this below command on a manager machine and running received command on a worker machine that has to be made for worker.

  • Docker swarm join-token worker1

To evaluate whether a worker has joined the swarm, go to manager machine and run a command. It will then list added worker machine along with the details of a manager.

Step 5:

Step five helps run to standard docker command on a manager.

Step 6:

The following step is to run a docker containers on docker swarm. With this, any service and replicas can be also created. For Thereafter, visit a Explore Depositaries, where can see various engine images. A Services and replicas can be created by using this command.

Here, ‘sample’ is a name of the service and 70 is a port that is be exposed. To check a service’s status, use this command on manager node.

  • docker service ls
  • docker service ps sample

Then, check a service running on all of nodes along with browser by providing IP for all of nodes.

Step 7:

Now, a next step is to see the real use of a docker swarm, where services can be scaled to up and down. On manager machine, run this command to scale a service.

  • docker service scale sample=4

This command mentioned above will run service sample on a 4 nodes. Even if all of nodes are busy already, another service on a worker or manager will created. Similarly, a service can be scaled down using a command.

  • docker service scale sample=2

The node can also be an inspected to get various details, such as which service and how many of them are running on the node. To do so, manager node will be used to run this command.

  • docker node inspect worker1/manager1
  • docker node inspect self

Step 8:

This step is to update a service when it is running on a various machines. Also, updating a service is quite simple process. For illustration, if wish to update a nginx service’s version, use this command:

  • docker service update –image nginx:1.10.0 sample

Step 9:

This one is last step that helps with a shutdown, stop or removal.To shut down of any specific node, command will be used.

  • docker node update –availability drain worker1

From all machines, to remove the specific service, this command will be used:

  • docker service rm sample

And, for machine to stop altogether, and would have to run these commands in a docker terminal.

  • docker-machine stop worker1
  • docker-machine rm worker1

Advantages of a Docker Swarm Architecture

Here are some of pointers that represent advantages of docker swarm architecture:

  • Swarm clusters can be simply managed by a swarm command.
  • To build the entire swarm, only a single point of an access is needed.
  • In comparison to the Kubernetes, docker swarm architecture is extremely be simple and straightforward.
  • The architecture comes with a high availability; thus, even if a master fails, some other worker node will be taking a charge.
  • The manager is going to keep track of a state of the cluster so as to keep consistency between an actual and desired state.

Conclusion

Being one of simplest tools, the Docker swarm can be used to the accomplish a variety of a tasks. With a swarm, a docker provides an orchestration as per requirement. Furthermore, when it comes to set up and also management, even that is hassle-free task.

Are you looking training with Right Jobs?

Contact Us

Popular Courses