1、前提:集群环境已经运行
在manager节点上执行:
bash
# 查看节点信息
>>> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
jr06s8pbrclkrxt7jpy7wae8t * iZ2ze78653g20ksebnllhpZ Ready Active Leader 20.10.16
4v3rwq67jrf6skao18zvjhlr0 rasp03 Ready Active 20.10.17
# 排空
>>> docker node update --availability drain 4v3rwq67jrf6skao18zvjhlr0
4v3rwq67jrf6skao18zvjhlr0
# 重启 节点
>>> docker node update --availability active 4v3rwq67jrf6skao18zvjhlr0
>>> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
jr06s8pbrclkrxt7jpy7wae8t * iZ2ze78653g20ksebnllhpZ Ready Active Leader 20.10.16
4v3rwq67jrf6skao18zvjhlr0 rasp03 Ready Drain 20.10.17
在worker节点上执行:
bash
# 主动申请离开集群
>>> docker swarm leave
Node left the swarm.
在manager节点上执行:
bash
>>> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
jr06s8pbrclkrxt7jpy7wae8t * iZ2ze78653g20ksebnllhpZ Ready Active Leader 20.10.16
4v3rwq67jrf6skao18zvjhlr0 rasp03 Down Drain 20.10.17
# 删除节点
>>> docker node rm 4v3rwq67jrf6skao18zvjhlr0
4v3rwq67jrf6skao18zvjhlr0
>>> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
jr06s8pbrclkrxt7jpy7wae8t * iZ2ze78653g20ksebnllhpZ Ready Active Leader 20.10.16