Docker swarm

Docker swarm

Docker Swarm :

Docker Swarm is a container orchestration tool That allows you to Create, Deploy, Scale, and manage a Cluster of Docker Hosts using a declarative configuration file called Docker Compose or DockerCLI.

Docker swarm ensures the deployment and maintenance of multiple containers and services for an application.

Manages a cluster of docker nodes.

Benefits :

Deployment

Scaling

Resource allocation

Load Balancing

Health Monitoring

Components :

Service : Defines task that need to be executed on the manager and worker nodes.

Task : They are the Docker container that execute commands

Manager Nodes : Takes the commands to create services, allocates IP's assign task

Worker node : Performs the task of running the container.

Initialize a swarm in a master node

sudo docker swarm init

Show docker nodes

sudo docker node ls

Create a Service:

docker service create --name <service-name> <image-name>

Show running service

docker service ls

Remove a service

docker service rm <service-name>

Join a swarm

docker swarm join --token <token>

Generate token from master

docker swarm join-token worker

Leave a swarm

docker swarm leave

Conclusion :

These are just a few Docker Swarm commands. Docker Swarm provides a comprehensive set of commands and options to manage services, nodes, networks, and other aspects of a Swarm cluster. You can explore more commands and their options in the Docker Swarm documentation for further details.