github.com/sld880311/docker@v0.0.0-20200524143708-d5593973a475/docs/reference/commandline/swarm_join.md (about) 1 --- 2 title: "swarm join" 3 description: "The swarm join command description and usage" 4 keywords: "swarm, join" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # swarm join 17 18 ```markdown 19 Usage: docker swarm join [OPTIONS] HOST:PORT 20 21 Join a swarm as a node and/or manager 22 23 Options: 24 --advertise-addr string Advertised address (format: <ip|interface>[:port]) 25 --help Print usage 26 --listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377) 27 --token string Token for entry into the swarm 28 ``` 29 30 ## Description 31 32 Join a node to a swarm. The node joins as a manager node or worker node based upon the token you 33 pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you 34 pass a worker token, the node joins as a worker. 35 36 ## Examples 37 38 ### Join a node to swarm as a manager 39 40 The example below demonstrates joining a manager node using a manager token. 41 42 ```bash 43 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377 44 This node joined a swarm as a manager. 45 $ docker node ls 46 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 47 dkp8vy1dq1kxleu9g4u78tlag * manager2 Ready Active Reachable 48 dvfxp4zseq4s0rih1selh0d20 manager1 Ready Active Leader 49 ``` 50 51 A cluster should only have 3-7 managers at most, because a majority of managers must be available 52 for the cluster to function. Nodes that aren't meant to participate in this management quorum 53 should join as workers instead. Managers should be stable hosts that have static IP addresses. 54 55 ### Join a node to swarm as a worker 56 57 The example below demonstrates joining a worker node using a worker token. 58 59 ```bash 60 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx 192.168.99.121:2377 61 This node joined a swarm as a worker. 62 $ docker node ls 63 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 64 7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active 65 dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active Reachable 66 dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader 67 ``` 68 69 ### `--listen-addr value` 70 71 If the node is a manager, it will listen for inbound swarm manager traffic on this 72 address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a 73 network interface to listen on that interface's address; for example `--listen-addr eth0:2377`. 74 75 Specifying a port is optional. If the value is a bare IP address, or interface 76 name, the default port 2377 will be used. 77 78 This flag is generally not necessary when joining an existing swarm. 79 80 ### `--advertise-addr value` 81 82 This flag specifies the address that will be advertised to other members of the 83 swarm for API access. If unspecified, Docker will check if the system has a 84 single IP address, and use that IP address with the listening port (see 85 `--listen-addr`). If the system has multiple IP addresses, `--advertise-addr` 86 must be specified so that the correct address is chosen for inter-manager 87 communication and overlay networking. 88 89 It is also possible to specify a network interface to advertise that interface's address; 90 for example `--advertise-addr eth0:2377`. 91 92 Specifying a port is optional. If the value is a bare IP address, or interface 93 name, the default port 2377 will be used. 94 95 This flag is generally not necessary when joining an existing swarm. 96 97 ### `--token string` 98 99 Secret value required for nodes to join the swarm 100 101 102 ## Related commands 103 104 * [swarm init](swarm_init.md) 105 * [swarm leave](swarm_leave.md) 106 * [swarm update](swarm_update.md)