github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/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 --availability string Availability of the node (active/pause/drain) (default "active") 26 --help Print usage 27 --listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377) 28 --token string Token for entry into the swarm 29 ``` 30 31 Join a node to a swarm. The node joins as a manager node or worker node based upon the token you 32 pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you 33 pass a worker token, the node joins as a worker. 34 35 ### Join a node to swarm as a manager 36 37 The example below demonstrates joining a manager node using a manager token. 38 39 ```bash 40 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377 41 This node joined a swarm as a manager. 42 $ docker node ls 43 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 44 dkp8vy1dq1kxleu9g4u78tlag * manager2 Ready Active Reachable 45 dvfxp4zseq4s0rih1selh0d20 manager1 Ready Active Leader 46 ``` 47 48 A cluster should only have 3-7 managers at most, because a majority of managers must be available 49 for the cluster to function. Nodes that aren't meant to participate in this management quorum 50 should join as workers instead. Managers should be stable hosts that have static IP addresses. 51 52 ### Join a node to swarm as a worker 53 54 The example below demonstrates joining a worker node using a worker token. 55 56 ```bash 57 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx 192.168.99.121:2377 58 This node joined a swarm as a worker. 59 $ docker node ls 60 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 61 7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active 62 dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active Reachable 63 dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader 64 ``` 65 66 ### `--listen-addr value` 67 68 If the node is a manager, it will listen for inbound swarm manager traffic on this 69 address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a 70 network interface to listen on that interface's address; for example `--listen-addr eth0:2377`. 71 72 Specifying a port is optional. If the value is a bare IP address, or interface 73 name, the default port 2377 will be used. 74 75 This flag is generally not necessary when joining an existing swarm. 76 77 ### `--advertise-addr value` 78 79 This flag specifies the address that will be advertised to other members of the 80 swarm for API access. If unspecified, Docker will check if the system has a 81 single IP address, and use that IP address with the listening port (see 82 `--listen-addr`). If the system has multiple IP addresses, `--advertise-addr` 83 must be specified so that the correct address is chosen for inter-manager 84 communication and overlay networking. 85 86 It is also possible to specify a network interface to advertise that interface's address; 87 for example `--advertise-addr eth0:2377`. 88 89 Specifying a port is optional. If the value is a bare IP address, or interface 90 name, the default port 2377 will be used. 91 92 This flag is generally not necessary when joining an existing swarm. 93 94 ### `--token string` 95 96 Secret value required for nodes to join the swarm 97 98 ### `--availability` 99 100 This flag specifies the availability of the node at the time the node joins a master. 101 Possible availability values are `active`, `pause`, or `drain`. 102 103 This flag is useful in certain situations. For example, a cluster may want to have 104 dedicated manager nodes that are not served as worker nodes. This could be achieved 105 by passing `--availability=drain` to `docker swarm join`. 106 107 108 ## Related information 109 110 * [swarm init](swarm_init.md) 111 * [swarm join-token](swarm_join_token.md) 112 * [swarm leave](swarm_leave.md) 113 * [swarm unlock](swarm_unlock.md) 114 * [swarm unlock-key](swarm_unlock_key.md) 115 * [swarm update](swarm_update.md)