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