github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/docs/reference/commandline/swarm_init.md (about) 1 <!--[metadata]> 2 +++ 3 title = "swarm init" 4 description = "The swarm init command description and usage" 5 keywords = ["swarm, init"] 6 [menu.main] 7 parent = "smn_cli" 8 +++ 9 <![end-metadata]--> 10 11 # swarm init 12 13 ```markdown 14 Usage: docker swarm init [OPTIONS] 15 16 Initialize a swarm 17 18 Options: 19 --advertise-addr value Advertised address (format: <ip|interface>[:port]) 20 --cert-expiry duration Validity period for node certificates (default 2160h0m0s) 21 --dispatcher-heartbeat duration Dispatcher heartbeat period (default 5s) 22 --external-ca value Specifications of one or more certificate signing endpoints 23 --force-new-cluster Force create a new cluster from current state. 24 --help Print usage 25 --listen-addr value Listen address (format: <ip|interface>[:port]) 26 --task-history-limit int Task history retention limit (default 5) 27 ``` 28 29 Initialize a swarm. The docker engine targeted by this command becomes a manager 30 in the newly created single-node swarm. 31 32 33 ```bash 34 $ docker swarm init --advertise-addr 192.168.99.121 35 Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager. 36 37 To add a worker to this swarm, run the following command: 38 39 docker swarm join \ 40 --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \ 41 172.17.0.2:2377 42 43 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. 44 ``` 45 46 `docker swarm init` generates two random tokens, a worker token and a manager token. When you join 47 a new node to the swarm, the node joins as a worker or manager node based upon the token you pass 48 to [swarm join](swarm_join.md). 49 50 After you create the swarm, you can display or rotate the token using 51 [swarm join-token](swarm_join_token.md). 52 53 ### `--cert-expiry` 54 55 This flag sets the validity period for node certificates. 56 57 ### `--dispatcher-heartbeat` 58 59 This flags sets the frequency with which nodes are told to use as a 60 period to report their health. 61 62 ### `--external-ca value` 63 64 This flag sets up the swarm to use an external CA to issue node certificates. The value takes 65 the form `protocol=X,url=Y`. The value for `protocol` specifies what protocol should be used 66 to send signing requests to the external CA. Currently, the only supported value is `cfssl`. 67 The URL specifies the endpoint where signing requests should be submitted. 68 69 ### `--force-new-cluster` 70 71 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. 72 73 ### `--listen-addr value` 74 75 The node listens for inbound Swarm manager traffic on this address. The default is to listen on 76 0.0.0.0:2377. It is also possible to specify a network interface to listen on that interface's 77 address; for example `--listen-addr eth0:2377`. 78 79 Specifying a port is optional. If the value is a bare IP address or interface 80 name, the default port 2377 will be used. 81 82 ### `--advertise-addr value` 83 84 This flag specifies the address that will be advertised to other members of the 85 swarm for API access and overlay networking. If unspecified, Docker will check 86 if the system has a single IP address, and use that IP address with with the 87 listening port (see `--listen-addr`). If the system has multiple IP addresses, 88 `--advertise-addr` must be specified so that the correct address is chosen for 89 inter-manager communication and overlay networking. 90 91 It is also possible to specify a network interface to advertise that interface's address; 92 for example `--advertise-addr eth0:2377`. 93 94 Specifying a port is optional. If the value is a bare IP address or interface 95 name, the default port 2377 will be used. 96 97 ### `--task-history-limit` 98 99 This flag sets up task history retention limit. 100 101 ## Related information 102 103 * [swarm join](swarm_join.md) 104 * [swarm leave](swarm_leave.md) 105 * [swarm update](swarm_update.md) 106 * [swarm join-token](swarm_join_token.md) 107 * [node rm](node_rm.md)