github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/reference/commandline/swarm_join-token.md (about) 1 --- 2 title: "swarm join-token" 3 description: "The swarm join-token command description and usage" 4 keywords: "swarm, join-token" 5 --- 6 7 # swarm join-token 8 9 ```markdown 10 Usage: docker swarm join-token [OPTIONS] (worker|manager) 11 12 Manage join tokens 13 14 Options: 15 --help Print usage 16 -q, --quiet Only display token 17 --rotate Rotate join token 18 ``` 19 20 ## Description 21 22 Join tokens are secrets that allow a node to join the swarm. There are two 23 different join tokens available, one for the worker role and one for the manager 24 role. You pass the token using the `--token` flag when you run 25 [swarm join](swarm_join.md). Nodes use the join token only when they join the 26 swarm. 27 28 > **Note** 29 > 30 > This is a cluster management command, and must be executed on a swarm 31 > manager node. To learn about managers and workers, refer to the 32 > [Swarm mode section](https://docs.docker.com/engine/swarm/) in the 33 > documentation. 34 35 ## Examples 36 37 You can view or rotate the join tokens using `swarm join-token`. 38 39 As a convenience, you can pass `worker` or `manager` as an argument to 40 `join-token` to print the full `docker swarm join` command to join a new node to 41 the swarm: 42 43 ```bash 44 $ docker swarm join-token worker 45 46 To add a worker to this swarm, run the following command: 47 48 docker swarm join \ 49 --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \ 50 172.17.0.2:2377 51 52 $ docker swarm join-token manager 53 54 To add a manager to this swarm, run the following command: 55 56 docker swarm join \ 57 --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 \ 58 172.17.0.2:2377 59 ``` 60 61 Use the `--rotate` flag to generate a new join token for the specified role: 62 63 ```bash 64 $ docker swarm join-token --rotate worker 65 66 Successfully rotated worker join token. 67 68 To add a worker to this swarm, run the following command: 69 70 docker swarm join \ 71 --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-b30ljddcqhef9b9v4rs7mel7t \ 72 172.17.0.2:2377 73 ``` 74 75 After using `--rotate`, only the new token will be valid for joining with the specified role. 76 77 The `-q` (or `--quiet`) flag only prints the token: 78 79 ```bash 80 $ docker swarm join-token -q worker 81 82 SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-b30ljddcqhef9b9v4rs7mel7t 83 ``` 84 85 ### `--rotate` 86 87 Because tokens allow new nodes to join the swarm, you should keep them secret. 88 Be particularly careful with manager tokens since they allow new manager nodes 89 to join the swarm. A rogue manager has the potential to disrupt the operation of 90 your swarm. 91 92 Rotate your swarm's join token if a token gets checked-in to version control, 93 stolen, or a node is compromised. You may also want to periodically rotate the 94 token to ensure any unknown token leaks do not allow a rogue node to join 95 the swarm. 96 97 To rotate the join token and print the newly generated token, run 98 `docker swarm join-token --rotate` and pass the role: `manager` or `worker`. 99 100 Rotating a join-token means that no new nodes will be able to join the swarm 101 using the old token. Rotation does not affect existing nodes in the swarm 102 because the join token is only used for authorizing new nodes joining the swarm. 103 104 ### `--quiet` 105 106 Only print the token. Do not print a complete command for joining. 107 108 ## Related commands 109 110 * [swarm ca](swarm_ca.md) 111 * [swarm init](swarm_init.md) 112 * [swarm join](swarm_join.md) 113 * [swarm leave](swarm_leave.md) 114 * [swarm unlock](swarm_unlock.md) 115 * [swarm unlock-key](swarm_unlock-key.md) 116 * [swarm update](swarm_update.md)