Skip to content

Docker SwarmΒΆ

A Docker Swarm is a cluster of Docker Daemons that can interact with each other. A Docker Swarm allows for decentralized design, scalability, load balancing, and overall cluster management. A Docker Swarm consists of a list of Docker Nodes (each running Docker Daemon). In each of those Docker Nodes, some Docker Services exist (a list of containers running from the same image). These services can then interact with each other through the swarm and Docker stack.

A Docker swarm consists of manager nodes, and worker nodes.

To initialize a swarm, run on your desired manager node:

docker swarm init --advertise-addr <MANAGER-IP>

Output:

Swarm initialized: current node (NODE_ID_HERE) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join \
    --token TOKEN_ID_HERE \
    MANAGER_NODE_IP_HERE:MANAGE_NODE_PORT_HERE

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

From there, you can follow the given insturctions on the worker nodes to add it to the swarm.

Now, you should be able to see all the nodes in the swarm using:

docker node ls