Search code examples
dockerdocker-swarm

Changing node to manager in docker swarm - what command should I use


I want to add manager to my docker swarm environment.
I can run update:
docker node update --role manager my_node_name
or promote
docker node promote my_node_name

Is there any difference between those two command?

Docker I'm on:

docker -v
Docker version 1.13.0, build 49bf474

Solution

  • If the node is a worker I think the result of the two commands are the same. The difference is IMO when you use this commands in scripts.

    root@docker-1:~# docker node promote docker-1
    Node 123123123123123 is already a manager.
    root@docker-1:~# echo $?
    0
    root@docker-1:~# docker node update docker-1 --role manager
    docker-1
    root@docker-1:~#
    

    which means the outputs (you can handle if you want) are different. Interesting that promote an already master is not an error.

    Your question's title is not what you ask in the description by the way. Adding a manager node to the swarm is as simple as using

    docker swarm join --token ...
    

    With a manger token you can add a manager node to the swarm in one step, and you don't need to promote it. (so this is a third way for creating a manager node)