Docker Community Forums

Share and learn in the Docker community.

Automatically join a new machine to swarm

Iā€™m trying to setup a docker swarm over GCP.
The GCP load balancer allocates new machines which are supposed to function as nodes.
How can I make sure these machines will join as nodes automatically without me having to type in the join command?

I can probably make the machines get all created using a disk snapshot that has a script that will run on the machine startup that will join the swarm. Is there a better way to configure it?

I have no experience with GCP, though here are some thoughts:

ā€“ make sure docker is installed
ā€“ make sure that the node is not a swarm member yet
ā€“ make sure to remove /etc/docker/key.json if it exists, as it stores the identity of the node
ā€“ when bootstrapping the new worker node, make sure to query the current tokent from one of the manager nodes. Do not join manager nodes this way, as it can lead to a state where your cluster becomes unmanagable!
ā€“ make sure to cleanup removed worker nodes regularily.

1 Like