github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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 # swarm join 8 9 ```markdown 10 Usage: docker swarm join [OPTIONS] HOST:PORT 11 12 Join a swarm as a node and/or manager 13 14 Options: 15 --advertise-addr string Advertised address (format: <ip|interface>[:port]) 16 --availability string Availability of the node ("active"|"pause"|"drain") (default "active") 17 --data-path-addr string Address or interface to use for data path traffic (format: <ip|interface>) 18 --help Print usage 19 --listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377) 20 --token string Token for entry into the swarm 21 ``` 22 23 ## Description 24 25 Join a node to a swarm. The node joins as a manager node or worker node based upon the token you 26 pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you 27 pass a worker token, the node joins as a worker. 28 29 ## Examples 30 31 ### Join a node to swarm as a manager 32 33 The example below demonstrates joining a manager node using a manager token. 34 35 ```bash 36 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377 37 This node joined a swarm as a manager. 38 $ docker node ls 39 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 40 dkp8vy1dq1kxleu9g4u78tlag * manager2 Ready Active Reachable 41 dvfxp4zseq4s0rih1selh0d20 manager1 Ready Active Leader 42 ``` 43 44 A cluster should only have 3-7 managers at most, because a majority of managers must be available 45 for the cluster to function. Nodes that aren't meant to participate in this management quorum 46 should join as workers instead. Managers should be stable hosts that have static IP addresses. 47 48 ### Join a node to swarm as a worker 49 50 The example below demonstrates joining a worker node using a worker token. 51 52 ```bash 53 $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx 192.168.99.121:2377 54 This node joined a swarm as a worker. 55 $ docker node ls 56 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 57 7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active 58 dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active Reachable 59 dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader 60 ``` 61 62 ### `--listen-addr value` 63 64 If the node is a manager, it will listen for inbound swarm manager traffic on this 65 address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a 66 network interface to listen on that interface's address; for example `--listen-addr eth0:2377`. 67 68 Specifying a port is optional. If the value is a bare IP address, or interface 69 name, the default port 2377 will be used. 70 71 This flag is generally not necessary when joining an existing swarm. 72 73 ### `--advertise-addr value` 74 75 This flag specifies the address that will be advertised to other members of the 76 swarm for API access. If unspecified, Docker will check if the system has a 77 single IP address, and use that IP address with the listening port (see 78 `--listen-addr`). If the system has multiple IP addresses, `--advertise-addr` 79 must be specified so that the correct address is chosen for inter-manager 80 communication and overlay networking. 81 82 It is also possible to specify a network interface to advertise that interface's address; 83 for example `--advertise-addr eth0:2377`. 84 85 Specifying a port is optional. If the value is a bare IP address, or interface 86 name, the default port 2377 will be used. 87 88 This flag is generally not necessary when joining an existing swarm. If 89 you're joining new nodes through a load balancer, you should use this flag to 90 ensure the node advertises its IP address and not the IP address of the load 91 balancer. 92 93 ### `--data-path-addr` 94 95 This flag specifies the address that global scope network drivers will publish towards 96 other nodes in order to reach the containers running on this node. 97 Using this parameter it is then possible to separate the container's data traffic from the 98 management traffic of the cluster. 99 If unspecified, Docker will use the same IP address or interface that is used for the 100 advertise address. 101 102 ### `--token string` 103 104 Secret value required for nodes to join the swarm 105 106 ### `--availability` 107 108 This flag specifies the availability of the node at the time the node joins a master. 109 Possible availability values are `active`, `pause`, or `drain`. 110 111 This flag is useful in certain situations. For example, a cluster may want to have 112 dedicated manager nodes that are not served as worker nodes. This could be achieved 113 by passing `--availability=drain` to `docker swarm join`. 114 115 116 ## Related commands 117 118 * [swarm ca](swarm_ca.md) 119 * [swarm init](swarm_init.md) 120 * [swarm join-token](swarm_join-token.md) 121 * [swarm leave](swarm_leave.md) 122 * [swarm unlock](swarm_unlock.md) 123 * [swarm unlock-key](swarm_unlock-key.md) 124 * [swarm update](swarm_update.md)