Docker Swarm
Docker Swarm provides clustering functionality for Docker Containers, which turns a group of Docker engines into a single virtual Docker engine.
Docker Swarm is an open-source container orchestration platform. It is the native orchestration tool by Docker. There are other orchesteration tools like Kubernetes from Google and Mesos from Apache.
A swarm consists of multiple Docker hosts which run in swarm mode and act as managers and workers. A given Docker host can be a manager, a worker, or perform both roles.
A node is an instance of the Docker engine participating in the swarm.
The following topics follows this tutorial
Create a Swarm
create a swarm. Current node will become a manager
1 | $ docker swarm init --advertise-addr 192.168.99.100 |
use docker node ls
to view information about the nodes
Add Node to Swarm
Workers can join a swarm using docker swarm join
command
1 | $ docker swarm join \ |
Leave a Swarm
Workers can leave a swarm by executing command docker swarm leave
1 | docker swarm leave |
Deploy a Service to the Swarm
1 | $ docker service create --replicas 1 --name helloworld alpine ping docker.com |
use docker service ls
to see list of running services
Scale the Service
1 | $ docker service scale helloworld=5 |
Remove the Service
1 | $ docker service rm helloworld |