How to add/remove nodes from Dockers swarm configuration ?

Categories:
Solution Number:
S34363
Last Modified:
2020-08-12
Issue
The following steps can help in editing a swarm without running the setup procedure on the nodes involved.
Solution
Removing a node from a swarm :
  • List the nodes in the swarm by running the following command on the Manager Node. 
    docker node ls
  • Log on to the desired node and run the following command to remove the node forcefully from the swarm.
    docker swarm leave -f
    The node will still appear in the node list on the Manager Node, but it will be marked as down. It no longer affects swarm operation.
  • To remove the node from the Managers list ( -f = forcefully)
    docker node rm <Node ID> -f
    The Node ID is seen in the output of the command in the first step.

Adding a node to a swarm :
  • The following command on the Manager Node displays the token for particular swarm. There are two; one for adding a Manager and one for a Worker.
    docker swarm join-token manager
    docker swarm join-token worker

    Tip - When adding a Core Node to a swarm use the worker form of the command.
  • The output of the above command tells you the next command which to be run on the node to be added to the swarm.
    See the example below

Environment
SteelCentral NetIM 2.x
Attachments
NOTICE: Riverbed® product names have changed. Please refer to the Product List for a complete list of product names.
Can't find an answer? Create a case