Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:
How to Disable Docker Swarm Mode?
Last updated: February 10, 2025
1. Overview
Docker Swarm is a built-in clustering and orchestration mechanism for Docker containers. It offers capabilities for deploying and maintaining services in a distributed environment and permits the administration of a cluster. Sometimes, though, we might want to turn off Docker Swarm mode, either to switch to another orchestration tool or just because we no longer need the clustering feature.
In this tutorial, we’ll walk through the step-by-step process of turning off the Docker Swarm mode.
2. Disabling Docker Swarm Mode
Before disabling Swarm mode, it’s important to understand the implications:
- Loss of Swarm Services: This action will stop and remove all the services running in the Swarm
- Node Removal: The node will leave the Swarm cluster, and if it’s the manager node, it will no longer manage the cluster
- Backup Data: Before disabling Swarm mode, ensure to back up any critical data or configurations
In order to disable the Docker Swarm Mode, we’ll first start by checking the current status using the docker info command. By doing so, the node’s involvement in a swarm will be verified. Next, we’ll exit the node from the cluster. Finally, we’ll verify the mode again to ensure the node is independent.
3. Check the Current Swarm Status
Let’s first identify if the current node is a part of the Swarm cluster. We can accomplish this by executing the below command:
$ docker info | grep Swarm
Swarm: active
The output mentions that the node is part of the Swarm cluster.
4. Leave the Swarm
We need to remove the Docker instance from the Swarm to disable the Swarm mode. To do this, we can use the command below:
$ docker swarm leave
Node left the default swarm.
This will remove the worker node from the swarm cluster. The node will remain tagged as down and visible in the node list. Use the node rm command to eliminate an inactive node from the list.
Note that the above command will be for worker nodes only. We can use the –flag to remove a manager node from the swarm:
$ docker swarm leave --force
We should use the –force flag only in single-node swarms or when the swarm will be decommissioned after the manager departs. The safe way to remove a manager from a swarm is to first demote it to a worker. Once demoted, simply instruct the node to leave the Swarm without using the –force flag.
By following these steps, we maintain the health and stability of the Docker Swarm cluster. This ensures that critical cluster state information is not inadvertently lost or corrupted.
5. Verify the Swarm Mode
Once all the nodes left the Swarm, confirm that Docker Swarm mode is disabled by running the docker info command again:
$ docker info | grep Swarm
Swarm: inactive
The output indicates that the Swarm mode is no longer active.
6. Remove Swarm-Specific Resources
After disabling the Swarm mode, let’s make sure to clear out any remaining states or configurations that might not be in use anymore. We should use the following commands to list and remove Docker networks:
$ docker network ls --filter driver=overlay
$ docker network rm <network_name>
The above command will list all the overlay Docker networks, and we can remove the desired network using the docker network rm command. Let’s also remove the volumes created by Swarm using the below command:
$ docker volume ls --filter label=com.docker.swarm
$ docker volume rm <volume_name>
Here, we first filter all the Docker volumes using the label com.docker.swarm. Further, we can delete those volumes using the docker volume rm command.
7. Conclusion
In this article, we learned the steps to disable the Docker Swarm mode. Disabling Docker Swarm mode is straightforward, but it’s important to understand the implications and take necessary precautions.
First, we identified the current state of the Swarm using the docker info command. Next, we disabled the Swarm by removing nodes one by one. Finally, we verified the state again to ensure the Swarm mode was disabled. This makes the transition to a simpler Docker setup or another orchestration tool.