docker swarm throwing an error "swarm already part of swarm"

The node you run docker swarm init on automatically becomes a Swarm Manager. Those join tokens are created for adding new nodes to the swarm to ensure you have a highly-available environment that is as resilient as possible.

Based on the comments I read above, you confirmed you were running the worker join token on the node you ran docker swarm init. I'd advise you read over the basics of Docker and Docker Swarm.


The Docker swarm is a collection of one or more machines (physical or virtual, called nodes) that can run your containers as services. Nodes in the swarm can be managers or workers. Only on manager nodes can you see/modify the swarm status. Worker nodes only run containers. In order to run a container in the swarm you must create a service; that service will have zero or more containers depending on the scale that you set for the service.

To create a swarm, you run the docker swarm init on the machine that will be a manager node. Then, on the other machines that you own you run the docker swarm join command in order to add them to the swarm. You cannot add to the swarm a machine that already is on the swarm. In your case, you try to add to the swarm the manager that created the swarm.

When you initiate a swarm (with docker swarm init), the machine from that you initiated the swarm is already connected to the swarm, you don't need to do anything else to connect it to the swarm.

After you initiate the swarm, you may (and should) add other machines as managers or workers.

At any point after you have created the swarm, you can create services and/or networks or deploy stacks.


I think you are using same Manager node for worker, I think it gonna make error. You can join a seperate node (can be virtual) as worker.

Type docker info and see the swarm state, you can find the state of swarm.

From the worker(different node) if you face "This node is already part of a swarm" , you should leave from swarm by " docker swarm leave --force". and try connecting again.