docker swarm leave
Description
Leave the swarm
API 1.24+ The client and daemon API must both be at least 1.24 to use this command. Use the docker version
command on the client to check your client and daemon API versions.
Swarm This command works with the Swarm orchestrator.
Usage
docker swarm leave [OPTIONS]
Options
Name, shorthand | Default | Description |
--force , -f |
Force this node to leave the swarm, ignoring warnings |
Parent command
Command | Description |
---|---|
docker swarm | Manage Swarm |
Related commands
Command | Description |
docker swarm ca | Display and rotate the root CA |
docker swarm init | Initialize a swarm |
docker swarm join | Join a swarm as a node and/or manager |
docker swarm join-token | Manage join tokens |
docker swarm leave | Leave the swarm |
docker swarm unlock | Unlock swarm |
docker swarm unlock-key | Manage the unlock key |
docker swarm update | Update the swarm |
Extended description
When you run this command on a worker, that worker leaves the swarm.
You can use the --force
option on a manager to remove it from the swarm. 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.
Examples
Consider the following swarm, as seen from the manager:
$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active
dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active
dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader
To remove worker2
, issue the following command from worker2
itself:
$ docker swarm leave
Node left the default swarm.
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
command.
© 2019 Docker, Inc.
Licensed under the Apache License, Version 2.0.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
https://docs.docker.com/v18.09/engine/reference/commandline/swarm_leave/