Adding nodes to a swarm

0 votes
I have created a swarm on a manager node (manager1). I want to add two worker nodes say worker1 and worker2 to the swarm.How to add these worker nodes?
Jul 8, 2019 in Docker by Sam
• 6,260 points
1,147 views

1 answer to this question.

0 votes

To Add Worker nodes :

  • Open a terminal and ssh into the machine where you want to run a worker node(worker1). 

  • Run the command docker swarm init to create a worker node joined to the existing swarm

$ docker swarm join \
  --token  SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
  192.168.99.100:2377

This node joined a swarm as a worker.
  • If you don’t have the command available, you can run the following command on a manager node to retrieve the join command for a worker:

$ docker swarm join-token worker

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

    docker swarm join \
    --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
    192.168.99.100:2377
  • Open a terminal and ssh into the machine where you want to run a second worker node (worker2).

  • Run the command docker swarm init to create a second worker node joined to the existing swarm:

$ docker swarm join \
  --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
  192.168.99.100:2377

This node joined a swarm as a worker.
  • Open a terminal and ssh into the machine where the manager node runs and run the docker node ls command to see the worker nodes:

ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
03g1y59jwfg7cf99w4lt0f662    worker2   Ready   Active
9j68exjopxe7wfl6yuxml7a7j    worker1   Ready   Active
dxn1zf6l61qsb1josjja83ngz *  manager1  Ready   Active        Leader

The MANAGER column identifies the manager nodes in the swarm. The empty status in this column for worker1 and worker2 identifies them as worker nodes.

Swarm management commands like docker node ls only work on manager nodes.

answered Jul 8, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

0 votes
1 answer
+3 votes
4 answers

Not able to connect worker nodes to the swarm. Connection refused error

This definitely has to be a firewall issue. ...READ MORE

answered Apr 26, 2019 in Docker by Vaidya
18,775 views
0 votes
1 answer

swarm manager does not connect to nodes docker daemons on AWS

You first need to ssh into the ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 7,060 points
1,841 views
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
3,925 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP