brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker swarm join-token prints, and rotates, the secret for new nodes

Docker
~/tips/tip-docker-swarm-join-token

docker swarm join-token worker

Shows the command to add a worker or manager node to a swarm, and can replace the token.

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

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link