github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/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 string           Advertised address (format: <ip|interface>[:port])
    25        --autolock                        Enable manager autolocking (requiring an unlock key to start a stopped manager)
    26        --availability string             Availability of the node ("active"|"pause"|"drain") (default "active")
    27        --cert-expiry duration            Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
    28        --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
    29        --external-ca external-ca         Specifications of one or more certificate signing endpoints
    30        --force-new-cluster               Force create a new cluster from current state
    31        --help                            Print usage
    32        --listen-addr node-addr           Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
    33        --max-snapshots uint              Number of additional Raft snapshots to retain
    34        --snapshot-interval uint          Number of log entries between Raft snapshots (default 10000)
    35        --task-history-limit int          Task history retention limit (default 5)
    36  ```
    37  
    38  ## Description
    39  
    40  Initialize a swarm. The docker engine targeted by this command becomes a manager
    41  in the newly created single-node swarm.
    42  
    43  ## Examples
    44  
    45  ```bash
    46  $ docker swarm init --advertise-addr 192.168.99.121
    47  Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager.
    48  
    49  To add a worker to this swarm, run the following command:
    50  
    51      docker swarm join \
    52      --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
    53      172.17.0.2:2377
    54  
    55  To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
    56  ```
    57  
    58  `docker swarm init` generates two random tokens, a worker token and a manager token. When you join
    59  a new node to the swarm, the node joins as a worker or manager node based upon the token you pass
    60  to [swarm join](swarm_join.md).
    61  
    62  After you create the swarm, you can display or rotate the token using
    63  [swarm join-token](swarm_join_token.md).
    64  
    65  ### `--autolock`
    66  
    67  This flag enables automatic locking of managers with an encryption key. The
    68  private keys and data stored by all managers will be protected by the
    69  encryption key printed in the output, and will not be accessible without it.
    70  Thus, it is very important to store this key in order to activate a manager
    71  after it restarts. The key can be passed to `docker swarm unlock` to reactivate
    72  the manager. Autolock can be disabled by running
    73  `docker swarm update --autolock=false`. After disabling it, the encryption key
    74  is no longer required to start the manager, and it will start up on its own
    75  without user intervention.
    76  
    77  ### `--cert-expiry`
    78  
    79  This flag sets the validity period for node certificates.
    80  
    81  ### `--dispatcher-heartbeat`
    82  
    83  This flag sets the frequency with which nodes are told to use as a
    84  period to report their health.
    85  
    86  ### `--external-ca`
    87  
    88  This flag sets up the swarm to use an external CA to issue node certificates. The value takes
    89  the form `protocol=X,url=Y`. The value for `protocol` specifies what protocol should be used
    90  to send signing requests to the external CA. Currently, the only supported value is `cfssl`.
    91  The URL specifies the endpoint where signing requests should be submitted.
    92  
    93  ### `--force-new-cluster`
    94  
    95  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.
    96  
    97  ### `--listen-addr`
    98  
    99  The node listens for inbound swarm manager traffic on this address. The default is to listen on
   100  0.0.0.0:2377. It is also possible to specify a network interface to listen on that interface's
   101  address; for example `--listen-addr eth0:2377`.
   102  
   103  Specifying a port is optional. If the value is a bare IP address or interface
   104  name, the default port 2377 will be used.
   105  
   106  ### `--advertise-addr`
   107  
   108  This flag specifies the address that will be advertised to other members of the
   109  swarm for API access and overlay networking. If unspecified, Docker will check
   110  if the system has a single IP address, and use that IP address with the
   111  listening port (see `--listen-addr`). If the system has multiple IP addresses,
   112  `--advertise-addr` must be specified so that the correct address is chosen for
   113  inter-manager communication and overlay networking.
   114  
   115  It is also possible to specify a network interface to advertise that interface's address;
   116  for example `--advertise-addr eth0:2377`.
   117  
   118  Specifying a port is optional. If the value is a bare IP address or interface
   119  name, the default port 2377 will be used.
   120  
   121  ### `--task-history-limit`
   122  
   123  This flag sets up task history retention limit.
   124  
   125  ### `--max-snapshots`
   126  
   127  This flag sets the number of old Raft snapshots to retain in addition to the
   128  current Raft snapshots. By default, no old snapshots are retained. This option
   129  may be used for debugging, or to store old snapshots of the swarm state for
   130  disaster recovery purposes.
   131  
   132  ### `--snapshot-interval`
   133  
   134  This flag specifies how many log entries to allow in between Raft snapshots.
   135  Setting this to a higher number will trigger snapshots less frequently.
   136  Snapshots compact the Raft log and allow for more efficient transfer of the
   137  state to new managers. However, there is a performance cost to taking snapshots
   138  frequently.
   139  
   140  ### `--availability`
   141  
   142  This flag specifies the availability of the node at the time the node joins a master.
   143  Possible availability values are `active`, `pause`, or `drain`.
   144  
   145  This flag is useful in certain situations. For example, a cluster may want to have
   146  dedicated manager nodes that are not served as worker nodes. This could be achieved
   147  by passing `--availability=drain` to `docker swarm init`.
   148  
   149  
   150  ## Related commands
   151  
   152  * [swarm join](swarm_join.md)
   153  * [swarm join-token](swarm_join_token.md)
   154  * [swarm leave](swarm_leave.md)
   155  * [swarm unlock](swarm_unlock.md)
   156  * [swarm unlock-key](swarm_unlock_key.md)
   157  * [swarm update](swarm_update.md)