-
Notifications
You must be signed in to change notification settings - Fork 0
2. Docker swarm setup
This section provides a step-by-step guide to setting up Docker Swarm on your system, including initializing the Swarm, adding nodes, and verifying the setup.
Ensure Docker is installed on all machines intended for the Swarm (both manager and worker nodes).
Networking configurations between nodes should allow for communication on ports Docker Swarm uses (e.g., TCP 2377, 7946, and UDP 4789).
- Initialize Docker Swarm
docker swarm init --advertise-addr <MANAGER_IP>
The --advertise-addr
option provides the IP address that Docker Swarm will use to connect with other nodes. This is particularly useful if your system has numerous network interfaces, such as in a cloud environment or a network that uses both public and private IP addresses.
- Add Worker Nodes to the Swarm
docker swarm join --token <JOIN_TOKEN> <MANAGER_IP>:2377
Replace <JOIN_TOKEN> and <MANAGER_IP> with the values from the docker swarm init output.
The IP address <MANAGER_IP> should match the --advertise-addr IP you specified when initializing the Swarm.
- If the docker swarm init output was cleared, you can retrieve the join token at any time from the manager node.
docker swarm join-token worker
- Verifying the Swarm Cluster
docker node ls