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