2016-06-14 02:57:19 +00:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
|
|
|
title = "swarm init"
|
|
|
|
description = "The swarm init command description and usage"
|
|
|
|
keywords = ["swarm, init"]
|
2016-06-20 11:54:53 +00:00
|
|
|
advisory = "rc"
|
2016-06-14 02:57:19 +00:00
|
|
|
[menu.main]
|
|
|
|
parent = "smn_cli"
|
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
|
|
|
|
|
|
|
# swarm init
|
|
|
|
|
2016-07-07 18:43:18 +00:00
|
|
|
```markdown
|
|
|
|
Usage: docker swarm init [OPTIONS]
|
|
|
|
|
2016-07-20 18:15:08 +00:00
|
|
|
Initialize a swarm
|
2016-07-07 18:43:18 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
--cert-expiry duration Validity period for node certificates (default 2160h0m0s)
|
|
|
|
--dispatcher-heartbeat duration Dispatcher heartbeat period (default 5s)
|
|
|
|
--external-ca value Specifications of one or more certificate signing endpoints
|
|
|
|
--force-new-cluster Force create a new cluster from current state.
|
|
|
|
--help Print usage
|
|
|
|
--listen-addr value Listen address (default 0.0.0.0:2377)
|
|
|
|
--task-history-limit int Task history retention limit (default 10)
|
|
|
|
```
|
2016-06-14 02:57:19 +00:00
|
|
|
|
2016-07-20 18:15:08 +00:00
|
|
|
Initialize a swarm cluster. The docker engine targeted by this command becomes a manager
|
|
|
|
in the newly created one node swarm cluster.
|
2016-06-14 02:57:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker swarm init --listen-addr 192.168.99.121:2377
|
2016-07-20 18:15:08 +00:00
|
|
|
Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager.
|
2016-07-05 22:39:26 +00:00
|
|
|
|
|
|
|
To add a worker to this swarm, run the following command:
|
2016-07-20 18:15:08 +00:00
|
|
|
docker swarm join \
|
|
|
|
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
|
|
|
|
172.17.0.2:2377
|
|
|
|
|
|
|
|
To add a manager to this swarm, run the following command:
|
|
|
|
docker swarm join \
|
|
|
|
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 \
|
|
|
|
172.17.0.2:2377
|
2016-06-14 02:57:19 +00:00
|
|
|
```
|
|
|
|
|
2016-07-20 18:15:08 +00:00
|
|
|
`docker swarm init` generates two random tokens, a worker token and a manager token. When you join
|
|
|
|
a new node to the swarm, the node joins as a worker or manager node based upon the token you pass
|
|
|
|
to [swarm join](swarm_join.md).
|
2016-06-29 21:01:25 +00:00
|
|
|
|
2016-07-20 18:15:08 +00:00
|
|
|
After you create the swarm, you can display or rotate the token using
|
|
|
|
[swarm join-token](swarm_join_token.md).
|
2016-07-12 20:06:01 +00:00
|
|
|
|
2016-07-07 18:43:18 +00:00
|
|
|
### `--cert-expiry`
|
|
|
|
|
|
|
|
This flag sets the validity period for node certificates.
|
|
|
|
|
|
|
|
### `--dispatcher-heartbeat`
|
|
|
|
|
|
|
|
This flags sets the frequency with which nodes are told to use as a
|
|
|
|
period to report their health.
|
|
|
|
|
2016-06-30 23:07:25 +00:00
|
|
|
### `--external-ca value`
|
|
|
|
|
|
|
|
This flag sets up the swarm to use an external CA to issue node certificates. The value takes
|
|
|
|
the form `protocol=X,url=Y`. The value for `protocol` specifies what protocol should be used
|
|
|
|
to send signing requests to the external CA. Currently, the only supported value is `cfssl`.
|
|
|
|
The URL specifies the endpoint where signing requests should be submitted.
|
|
|
|
|
2016-06-14 02:57:19 +00:00
|
|
|
### `--force-new-cluster`
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
### `--listen-addr value`
|
|
|
|
|
2016-07-20 18:15:08 +00:00
|
|
|
The node listens for inbound swarm manager traffic on this IP:PORT
|
2016-06-14 02:57:19 +00:00
|
|
|
|
2016-07-07 18:43:18 +00:00
|
|
|
### `--task-history-limit`
|
|
|
|
|
|
|
|
This flag sets up task history retention limit.
|
|
|
|
|
2016-06-14 02:57:19 +00:00
|
|
|
## Related information
|
|
|
|
|
|
|
|
* [swarm join](swarm_join.md)
|
|
|
|
* [swarm leave](swarm_leave.md)
|
|
|
|
* [swarm update](swarm_update.md)
|
2016-07-20 18:15:08 +00:00
|
|
|
* [swarm join-token](swarm_join_token.md)
|
2016-07-12 20:06:01 +00:00
|
|
|
* [node rm](node_rm.md)
|