github.com/panekj/cli@v0.0.0-20230304125325-467dd2f3797e/docs/reference/commandline/swarm_init.md (about)

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