#docker
# Docker Swarm
## Overview
Docker Swarm is a container orchestration tool that manages clusters of Docker nodes and services, allowing for scaling, load balancing, and easy deployment.
## Key Concepts
- **Swarm Mode**: Enables the cluster management and orchestration.
- **Node**: An instance of the Docker Engine participating in the swarm.
- **Manager Node**: Controls and manages the swarm.
- **Worker Node**: Executes containers and tasks.
- **Service**: A definition of how tasks are executed in the swarm.
- **Task**: A single instance of a container, part of a service.
## Commands
- Initialize swarm:
```bash
docker swarm init
```
- Join swarm:
```bash
docker swarm join --token <TOKEN> <MANAGER_IP>:<PORT>
```
- Create a service:
```bash
docker service create --name <service_name> <image>
```
- Scale a service:
```bash
docker service scale <service_name>=<replica_count>
```
- List services:
```bash
docker service ls
```
## Features
- **High Availability**: Redistributes tasks if nodes fail.х
- **Scaling**: Easily scale services up or down.
- **Load Balancing**: Automatic distribution of traffic across nodes.
- **Rolling Updates**: Update services without downtime.
## Swarm vs Kubernetes
- **Simplicity**: Swarm is simpler to set up.
- **Flexibility**: Kubernetes offers more features but is more complex.
- **Ecosystem**: Swarm integrates tightly with Docker. Kubernetes has a broader ecosystem.
## Useful Links
- [Official Docker Swarm Docs](https://docs.docker.com/engine/swarm/)