Adding a machine to a swarm needs a token, and I would not want to hunt for the one from the day it was created. A manager can print it again whenever you ask.
docker swarm join-token worker
docker swarm join-token manager
docker swarm join-token -q worker
The docs say join tokens are secrets that allow a node to join the swarm, with separate tokens for the worker and manager roles. The command must be run on a manager node. It prints a complete join command for that role, starting with the line “To add a worker to this swarm, run the following command:”. With -q (--quiet) you get only the token string, which suits a script.
I did not run this one, because it needs a swarm manager. The usage and options above come from the docs and docker swarm join-token --help.
If a token leaks, a node is compromised or you just want to be safe, rotate it:
docker swarm join-token --rotate worker
After that only the new token works for joining with that role. Rotation does not disconnect nodes that are already in the swarm, since a token only authorizes joining. The docs call the tokens secrets, so I’d treat them like passwords and keep them out of chat and screenshots.
Further reading: docker swarm join-token