2016-10-14 18:30:36 -04:00
|
|
|
---
|
|
|
|
title: "swarm join-token"
|
|
|
|
description: "The swarm join-token command description and usage"
|
2016-11-03 18:48:30 -04:00
|
|
|
keywords: "swarm, join-token"
|
2016-10-14 18:30:36 -04:00
|
|
|
---
|
2016-07-20 14:15:08 -04:00
|
|
|
|
2016-10-19 13:25:45 -04:00
|
|
|
<!-- This file is maintained within the docker/docker Github
|
|
|
|
repository at https://github.com/docker/docker/. Make all
|
|
|
|
pull requests against that repo. If you see this file in
|
|
|
|
another repository, consider it read-only there, as it will
|
|
|
|
periodically be overwritten by the definitive file. Pull
|
|
|
|
requests which include edits to this file in other repositories
|
|
|
|
will be rejected.
|
|
|
|
-->
|
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
# swarm join-token
|
|
|
|
|
|
|
|
```markdown
|
2016-08-17 03:45:04 -04:00
|
|
|
Usage: docker swarm join-token [OPTIONS] (worker|manager)
|
2016-07-20 14:15:08 -04:00
|
|
|
|
|
|
|
Manage join tokens
|
|
|
|
|
|
|
|
Options:
|
|
|
|
--help Print usage
|
|
|
|
-q, --quiet Only display token
|
|
|
|
--rotate Rotate join token
|
|
|
|
```
|
|
|
|
|
2016-07-28 00:24:38 -04:00
|
|
|
Join tokens are secrets that allow a node to join the swarm. There are two
|
|
|
|
different join tokens available, one for the worker role and one for the manager
|
|
|
|
role. You pass the token using the `--token` flag when you run
|
|
|
|
[swarm join](swarm_join.md). Nodes use the join token only when they join the
|
|
|
|
swarm.
|
2016-07-20 14:15:08 -04:00
|
|
|
|
2016-07-28 00:24:38 -04:00
|
|
|
You can view or rotate the join tokens using `swarm join-token`.
|
|
|
|
|
|
|
|
As a convenience, you can pass `worker` or `manager` as an argument to
|
|
|
|
`join-token` to print the full `docker swarm join` command to join a new node to
|
|
|
|
the swarm:
|
2016-07-20 14:15:08 -04:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker swarm join-token worker
|
|
|
|
To add a worker to this swarm, run the following command:
|
2016-07-27 10:14:29 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
docker swarm join \
|
|
|
|
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
|
|
|
|
172.17.0.2:2377
|
|
|
|
|
|
|
|
$ docker swarm join-token manager
|
|
|
|
To add a manager to this swarm, run the following command:
|
2016-07-27 10:14:29 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
docker swarm join \
|
|
|
|
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 \
|
|
|
|
172.17.0.2:2377
|
|
|
|
```
|
|
|
|
|
|
|
|
Use the `--rotate` flag to generate a new join token for the specified role:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker swarm join-token --rotate worker
|
2016-10-29 03:03:26 -04:00
|
|
|
Successfully rotated worker join token.
|
2016-07-27 10:14:29 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
To add a worker to this swarm, run the following command:
|
2016-07-27 10:14:29 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
docker swarm join \
|
|
|
|
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-b30ljddcqhef9b9v4rs7mel7t \
|
|
|
|
172.17.0.2:2377
|
|
|
|
```
|
|
|
|
|
|
|
|
After using `--rotate`, only the new token will be valid for joining with the specified role.
|
|
|
|
|
|
|
|
The `-q` (or `--quiet`) flag only prints the token:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker swarm join-token -q worker
|
2016-07-27 10:14:29 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-b30ljddcqhef9b9v4rs7mel7t
|
|
|
|
```
|
|
|
|
|
|
|
|
### `--rotate`
|
|
|
|
|
2016-07-28 00:24:38 -04:00
|
|
|
Because tokens allow new nodes to join the swarm, you should keep them secret.
|
|
|
|
Be particularly careful with manager tokens since they allow new manager nodes
|
|
|
|
to join the swarm. A rogue manager has the potential to disrupt the operation of
|
|
|
|
your swarm.
|
|
|
|
|
|
|
|
Rotate your swarm's join token if a token gets checked-in to version control,
|
|
|
|
stolen, or a node is compromised. You may also want to periodically rotate the
|
|
|
|
token to ensure any unknown token leaks do not allow a rogue node to join
|
|
|
|
the swarm.
|
|
|
|
|
|
|
|
To rotate the join token and print the newly generated token, run
|
|
|
|
`docker swarm join-token --rotate` and pass the role: `manager` or `worker`.
|
|
|
|
|
|
|
|
Rotating a join-token means that no new nodes will be able to join the swarm
|
|
|
|
using the old token. Rotation does not affect existing nodes in the swarm
|
|
|
|
because the join token is only used for authorizing new nodes joining the swarm.
|
2016-07-20 14:15:08 -04:00
|
|
|
|
|
|
|
### `--quiet`
|
|
|
|
|
|
|
|
Only print the token. Do not print a complete command for joining.
|
|
|
|
|
|
|
|
## Related information
|
|
|
|
|
2016-12-19 12:55:51 -05:00
|
|
|
* [swarm init](swarm_init.md)
|
2016-07-20 14:15:08 -04:00
|
|
|
* [swarm join](swarm_join.md)
|
2016-12-19 12:55:51 -05:00
|
|
|
* [swarm leave](swarm_leave.md)
|
|
|
|
* [swarm unlock](swarm_unlock.md)
|
|
|
|
* [swarm unlock-key](swarm_unlock_key.md)
|
|
|
|
* [swarm update](swarm_update.md)
|