Docker swarm common command - mnhmilu/poc-kubernets GitHub Wiki
Sure! Docker Swarm is a container orchestration platform that allows you to create and manage a cluster of Docker nodes. Here are some common Docker Swarm-related commands and concepts:
- Initialize a Swarm:
docker swarm init
- Join a node to the Swarm (run this command on other nodes to add them to the Swarm):
docker swarm join --token <TOKEN> <MANAGER_IP>:<MANAGER_PORT>
- Create a service (replicated or global mode):
docker service create --replicas <REPLICAS> --name <SERVICE_NAME> <IMAGE_NAME>
docker service create --mode global --name <SERVICE_NAME> <IMAGE_NAME>
- List all services in the Swarm:
docker service ls
- List tasks of a service:
docker service ps <SERVICE_NAME>
- Scale a service (increase or decrease the number of replicas):
docker service scale <SERVICE_NAME>=<REPLICAS>
- Update a service with a new image or configuration:
docker service update --image <NEW_IMAGE_NAME> <SERVICE_NAME>
- Remove a service from the Swarm:
docker service rm <SERVICE_NAME>
- List all nodes in the Swarm:
docker node ls
- Inspect a specific node:
docker node inspect <NODE_ID>
- Drain a node (prevent new tasks from being scheduled on the node):
docker node update --availability drain <NODE_ID>
- Promote a worker node to manager status:
docker node promote <NODE_ID>
- Demote a manager node to worker status:
docker node demote <NODE_ID>
- Leave the Swarm (run on a node to remove it from the Swarm):
docker swarm leave
- Leave the Swarm and remove the node from the manager:
docker swarm leave --force
These are some of the common commands used to interact with Docker Swarm. Docker Swarm provides a simple and powerful way to manage containerized applications in a cluster of Docker nodes.