2016-10-14 18:30:36 -04:00
|
|
|
---
|
|
|
|
title: "swarm join"
|
|
|
|
description: "The swarm join command description and usage"
|
2016-11-03 18:48:30 -04:00
|
|
|
keywords: "swarm, join"
|
2016-10-14 18:30:36 -04:00
|
|
|
---
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2016-10-19 13:25:45 -04:00
|
|
|
<!-- This file is maintained within the docker/docker Github
|
|
|
|
repository at https://github.com/docker/docker/. Make all
|
|
|
|
pull requests against that repo. If you see this file in
|
|
|
|
another repository, consider it read-only there, as it will
|
|
|
|
periodically be overwritten by the definitive file. Pull
|
|
|
|
requests which include edits to this file in other repositories
|
|
|
|
will be rejected.
|
|
|
|
-->
|
|
|
|
|
2016-06-13 22:57:19 -04:00
|
|
|
# swarm join
|
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
```markdown
|
|
|
|
Usage: docker swarm join [OPTIONS] HOST:PORT
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
Join a swarm as a node and/or manager
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
Options:
|
2016-12-11 07:21:31 -05:00
|
|
|
--advertise-addr string Advertised address (format: <ip|interface>[:port])
|
2016-12-21 21:06:16 -05:00
|
|
|
--availability string Availability of the node (active/pause/drain) (default "active")
|
2016-12-11 07:21:31 -05:00
|
|
|
--help Print usage
|
|
|
|
--listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
|
|
|
|
--token string Token for entry into the swarm
|
2016-07-07 14:43:18 -04:00
|
|
|
```
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
Join a node to a swarm. The node joins as a manager node or worker node based upon the token you
|
|
|
|
pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you
|
|
|
|
pass a worker token, the node joins as a worker.
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
### Join a node to swarm as a manager
|
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
The example below demonstrates joining a manager node using a manager token.
|
|
|
|
|
2016-06-13 22:57:19 -04:00
|
|
|
```bash
|
2016-06-30 21:07:35 -04:00
|
|
|
$ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377
|
2016-07-20 14:15:08 -04:00
|
|
|
This node joined a swarm as a manager.
|
2016-06-13 22:57:19 -04:00
|
|
|
$ docker node ls
|
2016-07-20 14:15:08 -04:00
|
|
|
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
|
|
|
dkp8vy1dq1kxleu9g4u78tlag * manager2 Ready Active Reachable
|
|
|
|
dvfxp4zseq4s0rih1selh0d20 manager1 Ready Active Leader
|
2016-06-13 22:57:19 -04:00
|
|
|
```
|
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
A cluster should only have 3-7 managers at most, because a majority of managers must be available
|
|
|
|
for the cluster to function. Nodes that aren't meant to participate in this management quorum
|
|
|
|
should join as workers instead. Managers should be stable hosts that have static IP addresses.
|
|
|
|
|
2016-06-13 22:57:19 -04:00
|
|
|
### Join a node to swarm as a worker
|
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
The example below demonstrates joining a worker node using a worker token.
|
|
|
|
|
2016-06-13 22:57:19 -04:00
|
|
|
```bash
|
2016-06-30 21:07:35 -04:00
|
|
|
$ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx 192.168.99.121:2377
|
2016-07-20 14:15:08 -04:00
|
|
|
This node joined a swarm as a worker.
|
2016-06-13 22:57:19 -04:00
|
|
|
$ docker node ls
|
2016-07-20 14:15:08 -04:00
|
|
|
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
|
|
|
7ln70fl22uw2dvjn2ft53m3q5 worker2 Ready Active
|
|
|
|
dkp8vy1dq1kxleu9g4u78tlag worker1 Ready Active Reachable
|
|
|
|
dvfxp4zseq4s0rih1selh0d20 * manager1 Ready Active Leader
|
2016-06-13 22:57:19 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
### `--listen-addr value`
|
|
|
|
|
2016-08-30 14:04:41 -04:00
|
|
|
If the node is a manager, it will listen for inbound swarm manager traffic on this
|
2016-06-30 21:07:35 -04:00
|
|
|
address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a
|
|
|
|
network interface to listen on that interface's address; for example `--listen-addr eth0:2377`.
|
|
|
|
|
2016-07-21 13:40:19 -04:00
|
|
|
Specifying a port is optional. If the value is a bare IP address, or interface
|
2016-06-30 21:07:35 -04:00
|
|
|
name, the default port 2377 will be used.
|
|
|
|
|
|
|
|
This flag is generally not necessary when joining an existing swarm.
|
|
|
|
|
|
|
|
### `--advertise-addr value`
|
|
|
|
|
|
|
|
This flag specifies the address that will be advertised to other members of the
|
|
|
|
swarm for API access. If unspecified, Docker will check if the system has a
|
2016-11-24 21:03:28 -05:00
|
|
|
single IP address, and use that IP address with the listening port (see
|
2016-06-30 21:07:35 -04:00
|
|
|
`--listen-addr`). If the system has multiple IP addresses, `--advertise-addr`
|
|
|
|
must be specified so that the correct address is chosen for inter-manager
|
|
|
|
communication and overlay networking.
|
|
|
|
|
|
|
|
It is also possible to specify a network interface to advertise that interface's address;
|
|
|
|
for example `--advertise-addr eth0:2377`.
|
|
|
|
|
2016-07-21 13:40:19 -04:00
|
|
|
Specifying a port is optional. If the value is a bare IP address, or interface
|
2016-06-30 21:07:35 -04:00
|
|
|
name, the default port 2377 will be used.
|
|
|
|
|
|
|
|
This flag is generally not necessary when joining an existing swarm.
|
|
|
|
|
2016-07-20 14:15:08 -04:00
|
|
|
### `--token string`
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
Secret value required for nodes to join the swarm
|
|
|
|
|
2016-12-21 21:06:16 -05:00
|
|
|
### `--availability`
|
|
|
|
|
|
|
|
This flag specifies the availability of the node at the time the node joins a master.
|
|
|
|
Possible availability values are `active`, `pause`, or `drain`.
|
|
|
|
|
|
|
|
This flag is useful in certain situations. For example, a cluster may want to have
|
|
|
|
dedicated manager nodes that are not served as worker nodes. This could be achieved
|
|
|
|
by passing `--availability=drain` to `docker swarm join`.
|
|
|
|
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
## Related information
|
|
|
|
|
|
|
|
* [swarm init](swarm_init.md)
|
2016-12-19 12:55:51 -05:00
|
|
|
* [swarm join-token](swarm_join_token.md)
|
2016-06-13 22:57:19 -04:00
|
|
|
* [swarm leave](swarm_leave.md)
|
2016-12-19 12:55:51 -05:00
|
|
|
* [swarm unlock](swarm_unlock.md)
|
|
|
|
* [swarm unlock-key](swarm_unlock_key.md)
|
2016-06-13 22:57:19 -04:00
|
|
|
* [swarm update](swarm_update.md)
|