Promote A Worker Node To Master
Promoting a node
You can promote any worker node to manager status at any time. To promote a node, run the below command on the manager node-
$ docker node promote NODE
Example-
first list the node.
root@master:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
buc72h0hyo66gcilq7melh9pq * master Ready Active Leader 20.10.11
xvdyauu8t83r3udrqh6c5w8a8 worker01 Ready Active 20.10.11
xctiaq0n14aew1falekqybq53 worker02 Ready Active 20.10.11
notice the manager status of worker01 and worker02 its blank in above output. now promote the worker01 and worker02 using below command.
root@master:~# docker node promote worker01 worker02
Node worker01 promoted to a manager in the swarm.
Node worker02 promoted to a manager in the swarm.
root@master:~#
List down the nodes again.
root@master:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
buc72h0hyo66gcilq7melh9pq * master Ready Active Leader 20.10.11
xvdyauu8t83r3udrqh6c5w8a8 worker01 Ready Active Reachable 20.10.11
xctiaq0n14aew1falekqybq53 worker02 Ready Active Reachable 20.10.11
root@master:~#
In the output, you can now see the MANAGER STATUS as a new column added. Now, you can run the docker node ls command on newly-promoted 2 nodes as well.
Note: Here we have promoted 2 more nodes to manager status that means now we have a total of three managers. This is because docker recommends an odd number of managers.