Explain Docker Swarm.
Docker engine is hosted on a particular host, with Docker Swarm we can start the same host on multiple machines. There will be a master machine(which is docker manager) and then we have different slaves/workers. Whatever service we start on manager, will be started on slaves.
Swarm command creates a network of Docker engines/ hosts to execute containers in parallel (for scaling up and high availability).
A Docker Swarm is a service that allows us to create and manage a cluster of Docker nodes and schedule containers. Each node of a Docker Swarm is a Docker daemon, and all Docker daemons interact using the Docker API. Each container within the Swarm can be deployed and accessed by nodes of the same cluster.
What are the features of Docker Swarm?
In Swarm, containers are launched using services, where a service is a group of containers of the same image that enables the scaling of applications. Before we can deploy a service in Docker Swarm, we must have at least one node deployed.
There are two types of nodes in Docker Swarm:
The worker nodes communicate with the manager node using API over HTTP. In Docker Swarm, services can be deployed and accessed by any node of the same cluster. While creating a service, you'll have to specify which container image you're going to use.
You can set up commands and services to be either global or replicated: a global service will run on every Swarm node, and on a replicated service, the manager node distributes tasks to worker nodes.
Docker engine is hosted on a particular host, with Docker Swarm we can start the same host on multiple machines. There will be a master machine(which is docker manager) and then we have different slaves/workers. Whatever service we start on manager, will be started on slaves.
Swarm command creates a network of Docker engines/ hosts to execute containers in parallel (for scaling up and high availability).
A Docker Swarm is a service that allows us to create and manage a cluster of Docker nodes and schedule containers. Each node of a Docker Swarm is a Docker daemon, and all Docker daemons interact using the Docker API. Each container within the Swarm can be deployed and accessed by nodes of the same cluster.
What are the features of Docker Swarm?
- Decentralized Access: Swarm makes it very easy for teams to access and manage the environment
- High Security: Any communication between the manager and client nodes within the Swarm is highly secure
- Auto Load Balancing: There is autoload balancing within your environment, and you can script that into how you write out and structure the Swarm environment
- High Scalability: Load balancing converts the Swarm environment into a highly scalable infrastructure
- Roll-back A Task: Swarm allows you to roll back environments to previous safe environments.
In Swarm, containers are launched using services, where a service is a group of containers of the same image that enables the scaling of applications. Before we can deploy a service in Docker Swarm, we must have at least one node deployed.
There are two types of nodes in Docker Swarm:
- Manager node: This node maintains cluster management tasks.
- Worker Node: It receives and executes tasks from the manager node.
The worker nodes communicate with the manager node using API over HTTP. In Docker Swarm, services can be deployed and accessed by any node of the same cluster. While creating a service, you'll have to specify which container image you're going to use.
You can set up commands and services to be either global or replicated: a global service will run on every Swarm node, and on a replicated service, the manager node distributes tasks to worker nodes.
Getting started with Swarm Mode
Manager intiate the Docker Swarm. Here the manager is the instance which starts the Swarm cluster. The command to start the cluster is:
$ docker swarm init --advertise-addr < ip-address >
Here, the '--advertise-addr’ flag is used for advertising itself to other nodes who want to join the cluster. We need to specify the IP address of the manager along with the flag.
When the Swarm cluster is initiated, a token is generated at the manager’s end. Other nodes use this token to join the swarm cluster.
Any node that joins the cluster can be later promoted to a manager, to do this we need to execute below command at the manager’s end:
$ docker swarm < join-token > manager
Later when we want the token for a node to join the cluster, we need to run the below command:
$ docker swarm < join-token > node
We need to execute the token at every node you want, to join the cluster.
To leave the swarm, use
$ docker swarm leave
OR to leave force-ably
$ docker swarm leave --force
-K Himaanshu Shuklaa..
No comments:
Post a Comment