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