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