...

Text file src/github.com/docker/cli/docs/reference/commandline/swarm_join.md

Documentation: github.com/docker/cli/docs/reference/commandline

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

View as plain text