github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/swarm_join.md (about)

     1  # swarm join
     2  
     3  <!---MARKER_GEN_START-->
     4  Join 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  
    21  Join a node to a swarm. The node joins as a manager node or worker node based upon the token you
    22  pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you
    23  pass a worker token, the node joins as a worker.
    24  
    25  ## Examples
    26  
    27  ### Join a node to swarm as a manager
    28  
    29  The 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
    33  This node joined a swarm as a manager.
    34  
    35  $ docker node ls
    36  ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
    37  dkp8vy1dq1kxleu9g4u78tlag *  manager2  Ready   Active        Reachable
    38  dvfxp4zseq4s0rih1selh0d20    manager1  Ready   Active        Leader
    39  ```
    40  
    41  A cluster should only have 3-7 managers at most, because a majority of managers must be available
    42  for the cluster to function. Nodes that aren't meant to participate in this management quorum
    43  should 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  
    47  The 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
    51  This node joined a swarm as a worker.
    52  
    53  $ docker node ls
    54  ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
    55  7ln70fl22uw2dvjn2ft53m3q5    worker2   Ready   Active
    56  dkp8vy1dq1kxleu9g4u78tlag    worker1   Ready   Active        Reachable
    57  dvfxp4zseq4s0rih1selh0d20 *  manager1  Ready   Active        Leader
    58  ```
    59  
    60  ### `--listen-addr value`
    61  
    62  If the node is a manager, it will listen for inbound swarm manager traffic on this
    63  address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a
    64  network interface to listen on that interface's address; for example `--listen-addr eth0:2377`.
    65  
    66  Specifying a port is optional. If the value is a bare IP address, or interface
    67  name, the default port 2377 will be used.
    68  
    69  This flag is generally not necessary when joining an existing swarm.
    70  
    71  ### `--advertise-addr value`
    72  
    73  This flag specifies the address that will be advertised to other members of the
    74  swarm for API access. If unspecified, Docker will check if the system has a
    75  single IP address, and use that IP address with the listening port (see
    76  `--listen-addr`). If the system has multiple IP addresses, `--advertise-addr`
    77  must be specified so that the correct address is chosen for inter-manager
    78  communication and overlay networking.
    79  
    80  It is also possible to specify a network interface to advertise that interface's address;
    81  for example `--advertise-addr eth0:2377`.
    82  
    83  Specifying a port is optional. If the value is a bare IP address, or interface
    84  name, the default port 2377 will be used.
    85  
    86  This flag is generally not necessary when joining an existing swarm. If
    87  you're joining new nodes through a load balancer, you should use this flag to
    88  ensure the node advertises its IP address and not the IP address of the load
    89  balancer.
    90  
    91  ### `--data-path-addr`
    92  
    93  This flag specifies the address that global scope network drivers will publish towards
    94  other nodes in order to reach the containers running on this node.
    95  Using this parameter it is then possible to separate the container's data traffic from the
    96  management traffic of the cluster.
    97  If unspecified, Docker will use the same IP address or interface that is used for the
    98  advertise address.
    99  
   100  ### `--token string`
   101  
   102  Secret value required for nodes to join the swarm
   103  
   104  ### `--availability`
   105  
   106  This flag specifies the availability of the node at the time the node joins a master.
   107  Possible availability values are `active`, `pause`, or `drain`.
   108  
   109  This flag is useful in certain situations. For example, a cluster may want to have
   110  dedicated manager nodes that are not served as worker nodes. This could be achieved
   111  by 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)