github.com/kim0/docker@v0.6.2-0.20161130212042-4addda3f07e7/docs/reference/commandline/swarm_init.md (about)

     1  ---
     2  title: "swarm init"
     3  description: "The swarm init command description and usage"
     4  keywords: ["swarm, init"]
     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 init
    17  
    18  ```markdown
    19  Usage:  docker swarm init [OPTIONS]
    20  
    21  Initialize a swarm
    22  
    23  Options:
    24        --advertise-addr value            Advertised address (format: <ip|interface>[:port])
    25        --cert-expiry duration            Validity period for node certificates (default 2160h0m0s)
    26        --dispatcher-heartbeat duration   Dispatcher heartbeat period (default 5s)
    27        --external-ca value               Specifications of one or more certificate signing endpoints
    28        --force-new-cluster               Force create a new cluster from current state.
    29        --help                            Print usage
    30        --listen-addr value               Listen address (format: <ip|interface>[:port])
    31        --task-history-limit int          Task history retention limit (default 5)
    32  ```
    33  
    34  Initialize a swarm. The docker engine targeted by this command becomes a manager
    35  in the newly created single-node swarm.
    36  
    37  
    38  ```bash
    39  $ docker swarm init --advertise-addr 192.168.99.121
    40  Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager.
    41  
    42  To add a worker to this swarm, run the following command:
    43  
    44      docker swarm join \
    45      --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
    46      172.17.0.2:2377
    47  
    48  To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
    49  ```
    50  
    51  `docker swarm init` generates two random tokens, a worker token and a manager token. When you join
    52  a new node to the swarm, the node joins as a worker or manager node based upon the token you pass
    53  to [swarm join](swarm_join.md).
    54  
    55  After you create the swarm, you can display or rotate the token using
    56  [swarm join-token](swarm_join_token.md).
    57  
    58  ### `--cert-expiry`
    59  
    60  This flag sets the validity period for node certificates.
    61  
    62  ### `--dispatcher-heartbeat`
    63  
    64  This flags sets the frequency with which nodes are told to use as a
    65  period to report their health.
    66  
    67  ### `--external-ca value`
    68  
    69  This flag sets up the swarm to use an external CA to issue node certificates. The value takes
    70  the form `protocol=X,url=Y`. The value for `protocol` specifies what protocol should be used
    71  to send signing requests to the external CA. Currently, the only supported value is `cfssl`.
    72  The URL specifies the endpoint where signing requests should be submitted.
    73  
    74  ### `--force-new-cluster`
    75  
    76  This flag forces an existing node that was part of a quorum that was lost to restart as a single node Manager without losing its data.
    77  
    78  ### `--listen-addr value`
    79  
    80  The node listens for inbound swarm manager traffic on this address. The default is to listen on
    81  0.0.0.0:2377. It is also possible to specify a network interface to listen on that interface's
    82  address; for example `--listen-addr eth0:2377`.
    83  
    84  Specifying a port is optional. If the value is a bare IP address or interface
    85  name, the default port 2377 will be used.
    86  
    87  ### `--advertise-addr value`
    88  
    89  This flag specifies the address that will be advertised to other members of the
    90  swarm for API access and overlay networking. If unspecified, Docker will check
    91  if the system has a single IP address, and use that IP address with with the
    92  listening port (see `--listen-addr`). If the system has multiple IP addresses,
    93  `--advertise-addr` must be specified so that the correct address is chosen for
    94  inter-manager communication and overlay networking.
    95  
    96  It is also possible to specify a network interface to advertise that interface's address;
    97  for example `--advertise-addr eth0:2377`.
    98  
    99  Specifying a port is optional. If the value is a bare IP address or interface
   100  name, the default port 2377 will be used.
   101  
   102  ### `--task-history-limit`
   103  
   104  This flag sets up task history retention limit.
   105  
   106  ## Related information
   107  
   108  * [swarm join](swarm_join.md)
   109  * [swarm leave](swarm_leave.md)
   110  * [swarm update](swarm_update.md)
   111  * [swarm join-token](swarm_join_token.md)
   112  * [node rm](node_rm.md)