github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/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/docker Github
     8       repository at https://github.com/docker/docker/. 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        --help                    Print usage
    27        --listen-addr node-addr   Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
    28        --token string            Token for entry into the swarm
    29  ```
    30  
    31  ## Description
    32  
    33  Join a node to a swarm. The node joins as a manager node or worker node based upon the token you
    34  pass with the `--token` flag. If you pass a manager token, the node joins as a manager. If you
    35  pass a worker token, the node joins as a worker.
    36  
    37  ## Examples
    38  
    39  ### Join a node to swarm as a manager
    40  
    41  The example below demonstrates joining a manager node using a manager token.
    42  
    43  ```bash
    44  $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377
    45  This node joined a swarm as a manager.
    46  $ docker node ls
    47  ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
    48  dkp8vy1dq1kxleu9g4u78tlag *  manager2  Ready   Active        Reachable
    49  dvfxp4zseq4s0rih1selh0d20    manager1  Ready   Active        Leader
    50  ```
    51  
    52  A cluster should only have 3-7 managers at most, because a majority of managers must be available
    53  for the cluster to function. Nodes that aren't meant to participate in this management quorum
    54  should join as workers instead. Managers should be stable hosts that have static IP addresses.
    55  
    56  ### Join a node to swarm as a worker
    57  
    58  The example below demonstrates joining a worker node using a worker token.
    59  
    60  ```bash
    61  $ docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx 192.168.99.121:2377
    62  This node joined a swarm as a worker.
    63  $ docker node ls
    64  ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
    65  7ln70fl22uw2dvjn2ft53m3q5    worker2   Ready   Active
    66  dkp8vy1dq1kxleu9g4u78tlag    worker1   Ready   Active        Reachable
    67  dvfxp4zseq4s0rih1selh0d20 *  manager1  Ready   Active        Leader
    68  ```
    69  
    70  ### `--listen-addr value`
    71  
    72  If the node is a manager, it will listen for inbound swarm manager traffic on this
    73  address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a
    74  network interface to listen on that interface's address; for example `--listen-addr eth0:2377`.
    75  
    76  Specifying a port is optional. If the value is a bare IP address, or interface
    77  name, the default port 2377 will be used.
    78  
    79  This flag is generally not necessary when joining an existing swarm.
    80  
    81  ### `--advertise-addr value`
    82  
    83  This flag specifies the address that will be advertised to other members of the
    84  swarm for API access. If unspecified, Docker will check if the system has a
    85  single IP address, and use that IP address with the listening port (see
    86  `--listen-addr`). If the system has multiple IP addresses, `--advertise-addr`
    87  must be specified so that the correct address is chosen for inter-manager
    88  communication and overlay networking.
    89  
    90  It is also possible to specify a network interface to advertise that interface's address;
    91  for example `--advertise-addr eth0:2377`.
    92  
    93  Specifying a port is optional. If the value is a bare IP address, or interface
    94  name, the default port 2377 will be used.
    95  
    96  This flag is generally not necessary when joining an existing swarm.
    97  
    98  ### `--token string`
    99  
   100  Secret value required for nodes to join the swarm
   101  
   102  ### `--availability`
   103  
   104  This flag specifies the availability of the node at the time the node joins a master.
   105  Possible availability values are `active`, `pause`, or `drain`.
   106  
   107  This flag is useful in certain situations. For example, a cluster may want to have
   108  dedicated manager nodes that are not served as worker nodes. This could be achieved
   109  by passing `--availability=drain` to `docker swarm join`.
   110  
   111  
   112  ## Related commands
   113  
   114  * [swarm init](swarm_init.md)
   115  * [swarm join-token](swarm_join_token.md)
   116  * [swarm leave](swarm_leave.md)
   117  * [swarm unlock](swarm_unlock.md)
   118  * [swarm unlock-key](swarm_unlock_key.md)
   119  * [swarm update](swarm_update.md)