github.com/kelda-inc/moby@v1.13.1/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 Join a node to a swarm. The node joins as a manager node or worker node based upon the token you 31 pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you 32 pass a worker token, the node joins as a worker. 33 34 ### Join a node to swarm as a manager 35 36 The example below demonstrates joining a manager node using a manager token. 37 38 ```bash 39 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377 40 This node joined a swarm as a manager. 41 $ docker node ls 42 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 43 dkp8vy1dq1kxleu9g4u78tlag * manager2 Ready Active Reachable 44 dvfxp4zseq4s0rih1selh0d20 manager1 Ready Active Leader 45 ``` 46 47 A cluster should only have 3-7 managers at most, because a majority of managers must be available 48 for the cluster to function. Nodes that aren't meant to participate in this management quorum 49 should join as workers instead. Managers should be stable hosts that have static IP addresses. 50 51 ### Join a node to swarm as a worker 52 53 The example below demonstrates joining a worker node using a worker token. 54 55 ```bash 56 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx 192.168.99.121:2377 57 This node joined a swarm as a worker. 58 $ docker node ls 59 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 60 7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active 61 dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active Reachable 62 dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader 63 ``` 64 65 ### `--listen-addr value` 66 67 If the node is a manager, it will listen for inbound swarm manager traffic on this 68 address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a 69 network interface to listen on that interface's address; for example `--listen-addr eth0:2377`. 70 71 Specifying a port is optional. If the value is a bare IP address, or interface 72 name, the default port 2377 will be used. 73 74 This flag is generally not necessary when joining an existing swarm. 75 76 ### `--advertise-addr value` 77 78 This flag specifies the address that will be advertised to other members of the 79 swarm for API access. If unspecified, Docker will check if the system has a 80 single IP address, and use that IP address with the listening port (see 81 `--listen-addr`). If the system has multiple IP addresses, `--advertise-addr` 82 must be specified so that the correct address is chosen for inter-manager 83 communication and overlay networking. 84 85 It is also possible to specify a network interface to advertise that interface's address; 86 for example `--advertise-addr eth0:2377`. 87 88 Specifying a port is optional. If the value is a bare IP address, or interface 89 name, the default port 2377 will be used. 90 91 This flag is generally not necessary when joining an existing swarm. 92 93 ### `--token string` 94 95 Secret value required for nodes to join the swarm 96 97 98 ## Related information 99 100 * [swarm init](swarm_init.md) 101 * [swarm leave](swarm_leave.md) 102 * [swarm update](swarm_update.md)