Leave node from Docker Swarm cluster

docker swarm leave
17 March 2025

Run the command "docker swarm leave"

In the basic processes regarding Docker, especially when we talk about Docker Swarm, it is necessary to manage clusters properly and appropriately. Docker Swarm gives you the possibility to manage multiple machines as a single cluster and effectively distribute your resources. However, there may be times when you want to remove a specific node (or worker) from the entire cluster. Here is where the command "docker swarm leave" comes into play.
This command enables you to remove a node from the Docker Swarm cluster. You might want to remove an old node or for any reason separate a node from the cluster. This operation typically takes place when you need to redeploy resources or simply remove a node from its current state.
Executing this command can generally be straightforward, but one key point to keep in mind is that when you remove a node from the cluster, that node will no longer be considered part of that cluster and will not hold any tasks anymore.
Keep in mind that if this node is the Leader, you must elect a new node as the leader. Therefore, before you want to remove a node, make sure that its management has been correctly carried out to prevent future issues.

How to use "docker swarm leave"

To leave a node from the Docker Swarm cluster, you can use the following command:
docker swarm leave
This command simply allows you to exit the cluster. If you want to consider this action as a manager node, you can use the option --force:
docker swarm leave --force
This option is useful when you do not want to proceed with the regular process of leaving the node.

Error explanation

docker swarm leave
This command will easily remove the current node from the Docker Swarm cluster. This action is performed without any confirmation, and all resources related to this node will be freed.
docker swarm leave --force
This command is similar to the previous command, but with the difference that even if the node is a manager, it will be removed quickly without any approval or special process.

FAQ

?

Why should I remove a node from the Docker Swarm cluster?

?

Can I remove a manager node?

?

After removing a node, are its resources freed?

?

When should I use the --force option?