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