2016-06-13 22:57:19 -04:00
|
|
|
# swarm leave
|
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
<!---MARKER_GEN_START-->
|
2016-12-16 09:10:20 -05:00
|
|
|
Leave the swarm
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
### Options
|
|
|
|
|
2024-07-03 02:29:57 -04:00
|
|
|
| Name | Type | Default | Description |
|
|
|
|
|:----------------|:-------|:--------|:------------------------------------------------------|
|
|
|
|
| `-f`, `--force` | `bool` | | Force this node to leave the swarm, ignoring warnings |
|
2023-01-06 13:04:05 -05:00
|
|
|
|
|
|
|
|
|
|
|
<!---MARKER_GEN_END-->
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Description
|
|
|
|
|
2016-09-01 18:38:25 -04:00
|
|
|
When you run this command on a worker, that worker leaves the swarm.
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2017-02-06 20:31:55 -05:00
|
|
|
You can use the `--force` option on a manager to remove it from the swarm.
|
2016-09-01 18:38:25 -04:00
|
|
|
However, this does not reconfigure the swarm to ensure that there are enough
|
|
|
|
managers to maintain a quorum in the swarm. The safe way to remove a manager
|
|
|
|
from a swarm is to demote it to a worker and then direct it to leave the quorum
|
|
|
|
without using `--force`. Only use `--force` in situations where the swarm will
|
|
|
|
no longer be used after the manager leaves, such as in a single-node swarm.
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Examples
|
|
|
|
|
2016-09-01 18:38:25 -04:00
|
|
|
Consider the following swarm, as seen from the manager:
|
2017-02-07 18:42:48 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-06-13 22:57:19 -04:00
|
|
|
$ docker node ls
|
2020-04-19 09:43:08 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
|
|
|
7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active
|
2016-09-01 18:38:25 -04:00
|
|
|
dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active
|
2016-07-20 14:15:08 -04:00
|
|
|
dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader
|
2016-06-13 22:57:19 -04:00
|
|
|
```
|
|
|
|
|
2016-09-01 18:38:25 -04:00
|
|
|
To remove `worker2`, issue the following command from `worker2` itself:
|
2017-02-07 13:09:32 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-06-13 22:57:19 -04:00
|
|
|
$ docker swarm leave
|
2020-04-19 09:43:08 -04:00
|
|
|
|
2016-06-13 22:57:19 -04:00
|
|
|
Node left the default swarm.
|
|
|
|
```
|
2017-02-07 13:09:32 -05:00
|
|
|
|
|
|
|
The node will still appear in the node list, and marked as `down`. It no longer
|
|
|
|
affects swarm operation, but a long list of `down` nodes can clutter the node
|
|
|
|
list. To remove an inactive node from the list, use the [`node rm`](node_rm.md)
|
|
|
|
command.
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Related commands
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2017-05-10 18:34:56 -04:00
|
|
|
* [swarm ca](swarm_ca.md)
|
2016-09-01 18:38:25 -04:00
|
|
|
* [node rm](node_rm.md)
|
2016-06-13 22:57:19 -04:00
|
|
|
* [swarm init](swarm_init.md)
|
|
|
|
* [swarm join](swarm_join.md)
|
2020-04-19 09:43:08 -04:00
|
|
|
* [swarm join-token](swarm_join-token.md)
|
2016-12-19 12:55:51 -05:00
|
|
|
* [swarm unlock](swarm_unlock.md)
|
2020-04-19 09:43:08 -04:00
|
|
|
* [swarm unlock-key](swarm_unlock-key.md)
|
2016-06-13 22:57:19 -04:00
|
|
|
* [swarm update](swarm_update.md)
|