Reputation: 3336
I've created a docker-machine swarm cluster using a new generated token, which was stored within an environment variable. The environment variable was only for valid for the current session, and is deleted afterward. Now I want to add a new docker-machine to the same cluster, but I can't find the needed token.
How is it possible to find out the token used by an active docker swarm ?
Upvotes: 15
Views: 25319
Reputation: 16152
Just ssh
into manager and get the tokens, like the following.
# get manager and worker tokens
export MANAGER_TOKEN=`docker-machine ssh $SWARM_AGENT_MASTER "docker swarm join-token manager -q"`
export WORKER_TOKEN=`docker-machine ssh $SWARM_AGENT_MASTER "docker swarm join-token worker -q"`
Upvotes: 2
Reputation: 676
Answering for posterity, since I had no luck with the other answer.
Running Docker 17.05. Docker can now list join tokens for both workers and managers.
$ docker swarm join-token manager
To add a manager to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-13z9uafwgjdkfv3ik18ttceqgtogdqr4xurhc6vaybeckx7i7u-2lnnyzeqb93ejgjrdlivsg7rf \
10.0.0.18:2377
$ docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-13z9uafwgjdkfv3ik18ttceqgtogdqr4xurhc6vaybeckx7i7u-b3a28we1he23rxwk2rea933y4 \
10.0.0.18:2377
More information: https://docs.docker.com/engine/reference/commandline/swarm_join-token/
Upvotes: 53
Reputation: 86
This article explains how this can be achieved:
Getting the Docker Swarm Discovery Token
Execute: docker inspect $SWARM_AGENT_MASTER
where $SWARM_AGENT_MASTER
is the name of the container.
Upvotes: 2