General knowledge about Docker and Docker Swarm (Part 4 – History, Docker Swarm structure)

Tram Ho

I. Concept, reason for birth

  • Docker compose is a tool used to define and run multi-containers for Docker applications. With compose you use the YAML file to configure the services for your application.
  • However, Docker Compose is only applicable on a single Docker host, which limits the hardware configuration that the Docker host system can provide, making it difficult to scale up the service processing capabilities. and increasing the number of Docker Containers corresponding to that service becomes difficult.

=> From there, Orchestration was born

  • Orchestration is a term used to refer to container scheduling, cluster management, and the ability to provision additional servers.
  • Container Orchestration is all about managing the lifecycle of containers, especially in large environments, such as:
    • Container provisioning and deployment
    • Cluster Management
    • Expand or remove containers to distribute application load evenly across the server infrastructure
    • Move containers from one host to another if there is a shortage of resources on a certain host, or if a host dies.
    • Allocate resources between containers,…

So what is Docker Swarm, related to orchestration??

  • Docker Swarm is one of the open source orchestration solutions besides Kubernetes, Apache Mesos, etc. It supports the creation and management of containers or Container Orchestration systems. It is a cluster where users manage Docker Engines or nodes to deploy services up and running.
  • Can work on many different platforms such as Windows, Linux, MacOS. In addition, Docker also supports many famous cloud computing services such as Microsoft Azure or Amazon Web Services.

Before using Docker Swarm

After using Docker Swarm

II. Benefits of using

Docker Swarm has 3 main benefits:

  • Leverage the power of Containers: Containers allow developers to deploy applications or services in a standalone virtual environment, a task that previously belonged to virtual machines.
  • Ensure high service availability: a Docker Swarm has a manager that can assign tasks to Worker nodes. By implementing multiple managers, developers ensure that the system can continue to function even if one of the Manager nodes fails.
  • Automatic Load Balancing: Docker swarm schedules tasks using a variety of methods to ensure that there are enough resources available for all containers, helping to ensure that specified container workloads run on the most suitable host for optimal efficiency

III. Structure

Docker Swarm consists of 2 main components

1. Swarm (Cluster)

A set of nodes has at least one master node and several worker nodes which can be virtual or physical.

2. Node

Each node of a Docker Swarm is a Docker Host / Docker daemon and all Docker daemons use the docker API. Normally will use docker-machine using VirtualBox or HyperV virtual machine. Nodes are of two types:

  • Manager node: This is the node that holds all the management rights and distributes the work to the rest of the nodes (Worker Node) in the swarm. Usually there is only 1 Manager Node in Swarm. Perform the following functions:
    • It distributes work (as tasks) to worker nodes,
    • Manage the state of the swarm to which it belongs.
  • Worker Node As a Node belonging to Swarm but not a Node Manager, execute and report the work results to the Manager Node(s).
    • The worker nodes run the tasks distributed by the node manager
    • Each worker node runs an agent that reports back to the master node on the status of the tasks assigned to it, so the node manager can monitor the services and tasks running in the swarm.

3. Service

  • Similar to Docker Compose, users use a service definition to declare information about the Image, the number of Containers – replicas, network, ports and storages.
  • Based on this declaration, the manager nodes split the service into units of tasks, which are distributed to the work nodes.
  • If a worker node is down for some reason, the manager node will redirect tasks to other worker nodes to ensure the required status of the service.

4. Task

  • Swarm defines a Task as a container that is performing a part of the work required in the swarm service, and placed under the management of the manager node.
  • The node managers assign tasks to worker nodes, and after this assignment, the task cannot be transferred to another worker. If the task fails in the replica set, the manager assigns a new instance of the task to another available node in the swarm.
  • Swarm defines a Task as a container that is performing a part of the work required in the swarm service, and placed under the management of the manager node.
  • The node managers assign tasks to worker nodes, and after this assignment, the task cannot be transferred to another worker. If the task fails in the replica set, the manager assigns a new instance of the task to another available node in the swarm.

References

[1]. How node works

[2]. Docker docs

[3]. Docker là gì?

Share the news now