github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/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/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 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        --data-path-addr string           Address or interface to use for data path traffic (format: <ip|interface>)
    29        --data-path-port uint32           Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the default port (4789) is used.
    30        --default-addr-pool IPnet         List of default address pool (format: <cidr>)
    31        --default-addr-pool-mask-length   Subnet mask length for default address pool (default 24)
    32        --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
    33        --external-ca external-ca         Specifications of one or more certificate signing endpoints
    34        --force-new-cluster               Force create a new cluster from current state
    35        --help                            Print usage
    36        --listen-addr node-addr           Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
    37        --max-snapshots uint              Number of additional Raft snapshots to retain
    38        --snapshot-interval uint          Number of log entries between Raft snapshots (default 10000)
    39        --task-history-limit int          Task history retention limit (default 5)
    40  ```
    41  
    42  ## Description
    43  
    44  Initialize a swarm. The docker engine targeted by this command becomes a manager
    45  in the newly created single-node swarm.
    46  
    47  ## Examples
    48  
    49  ```bash
    50  $ docker swarm init --advertise-addr 192.168.99.121
    51  Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager.
    52  
    53  To add a worker to this swarm, run the following command:
    54  
    55      docker swarm join \
    56      --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
    57      172.17.0.2:2377
    58  
    59  To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
    60  ```
    61  
    62  `docker swarm init` generates two random tokens, a worker token and a manager token. When you join
    63  a new node to the swarm, the node joins as a worker or manager node based upon the token you pass
    64  to [swarm join](swarm_join.md).
    65  
    66  After you create the swarm, you can display or rotate the token using
    67  [swarm join-token](swarm_join_token.md).
    68  
    69  ### `--autolock`
    70  
    71  This flag enables automatic locking of managers with an encryption key. The
    72  private keys and data stored by all managers will be protected by the
    73  encryption key printed in the output, and will not be accessible without it.
    74  Thus, it is very important to store this key in order to activate a manager
    75  after it restarts. The key can be passed to `docker swarm unlock` to reactivate
    76  the manager. Autolock can be disabled by running
    77  `docker swarm update --autolock=false`. After disabling it, the encryption key
    78  is no longer required to start the manager, and it will start up on its own
    79  without user intervention.
    80  
    81  ### `--cert-expiry`
    82  
    83  This flag sets the validity period for node certificates.
    84  
    85  ### `--dispatcher-heartbeat`
    86  
    87  This flag sets the frequency with which nodes are told to use as a
    88  period to report their health.
    89  
    90  ### `--external-ca`
    91  
    92  This flag sets up the swarm to use an external CA to issue node certificates. The value takes
    93  the form `protocol=X,url=Y`. The value for `protocol` specifies what protocol should be used
    94  to send signing requests to the external CA. Currently, the only supported value is `cfssl`.
    95  The URL specifies the endpoint where signing requests should be submitted.
    96  
    97  ### `--force-new-cluster`
    98  
    99  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.
   100  
   101  ### `--listen-addr`
   102  
   103  The node listens for inbound swarm manager traffic on this address. The default is to listen on
   104  0.0.0.0:2377. It is also possible to specify a network interface to listen on that interface's
   105  address; for example `--listen-addr eth0:2377`.
   106  
   107  Specifying a port is optional. If the value is a bare IP address or interface
   108  name, the default port 2377 will be used.
   109  
   110  ### `--advertise-addr`
   111  
   112  This flag specifies the address that will be advertised to other members of the
   113  swarm for API access and overlay networking. If unspecified, Docker will check
   114  if the system has a single IP address, and use that IP address with the
   115  listening port (see `--listen-addr`). If the system has multiple IP addresses,
   116  `--advertise-addr` must be specified so that the correct address is chosen for
   117  inter-manager communication and overlay networking.
   118  
   119  It is also possible to specify a network interface to advertise that interface's address;
   120  for example `--advertise-addr eth0:2377`.
   121  
   122  Specifying a port is optional. If the value is a bare IP address or interface
   123  name, the default port 2377 will be used.
   124  
   125  ### `--data-path-addr`
   126  
   127  This flag specifies the address that global scope network drivers will publish towards
   128  other nodes in order to reach the containers running on this node.
   129  Using this parameter it is then possible to separate the container's data traffic from the
   130  management traffic of the cluster.
   131  If unspecified, Docker will use the same IP address or interface that is used for the
   132  advertise address.
   133  
   134  ### `--data-path-port`
   135  
   136  This flag allows you to configure the UDP port number to use for data path
   137  traffic. The provided port number must be within the 1024 - 49151 range. If
   138  this flag is not set or is set to 0, the default port number 4789 is used.
   139  The data path port can only be configured when initializing the swarm, and
   140  applies to all nodes that join the swarm.
   141  The following example initializes a new Swarm, and configures the data path
   142  port to UDP port 7777;
   143  
   144  ```bash
   145  docker swarm init --data-path-port=7777
   146  ```
   147  After the swarm is initialized, use the `docker info` command to verify that
   148  the port is configured:
   149  
   150  ```bash
   151  docker info
   152  	...
   153  	ClusterID: 9vs5ygs0gguyyec4iqf2314c0
   154  	Managers: 1
   155  	Nodes: 1
   156  	Data Path Port: 7777
   157  	...
   158  ```
   159  
   160  ### `--default-addr-pool`
   161  This flag specifies default subnet pools for global scope networks.
   162  Format example is `--default-addr-pool 30.30.0.0/16 --default-addr-pool 40.40.0.0/16`
   163  
   164  ### `--default-addr-pool-mask-length`
   165  This flag specifies default subnet pools mask length for default-addr-pool.
   166  Format example is `--default-addr-pool-mask-length 24`
   167  
   168  ### `--task-history-limit`
   169  
   170  This flag sets up task history retention limit.
   171  
   172  ### `--max-snapshots`
   173  
   174  This flag sets the number of old Raft snapshots to retain in addition to the
   175  current Raft snapshots. By default, no old snapshots are retained. This option
   176  may be used for debugging, or to store old snapshots of the swarm state for
   177  disaster recovery purposes.
   178  
   179  ### `--snapshot-interval`
   180  
   181  This flag specifies how many log entries to allow in between Raft snapshots.
   182  Setting this to a higher number will trigger snapshots less frequently.
   183  Snapshots compact the Raft log and allow for more efficient transfer of the
   184  state to new managers. However, there is a performance cost to taking snapshots
   185  frequently.
   186  
   187  ### `--availability`
   188  
   189  This flag specifies the availability of the node at the time the node joins a master.
   190  Possible availability values are `active`, `pause`, or `drain`.
   191  
   192  This flag is useful in certain situations. For example, a cluster may want to have
   193  dedicated manager nodes that are not served as worker nodes. This could be achieved
   194  by passing `--availability=drain` to `docker swarm init`.
   195  
   196  
   197  ## Related commands
   198  
   199  * [swarm ca](swarm_ca.md)
   200  * [swarm join](swarm_join.md)
   201  * [swarm join-token](swarm_join_token.md)
   202  * [swarm leave](swarm_leave.md)
   203  * [swarm unlock](swarm_unlock.md)
   204  * [swarm unlock-key](swarm_unlock_key.md)
   205  * [swarm update](swarm_update.md)