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]
|
|
|
|
|
|
|
|
Initialize a Swarm
|
|
|
|
|
|
|
|
Options:
|
|
|
|
--auto-accept value Auto acceptance policy (worker, manager or none)
|
|
|
|
--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)
|
|
|
|
--secret string Set secret value needed to accept nodes into cluster
|
|
|
|
--task-history-limit int Task history retention limit (default 10)
|
|
|
|
```
|
2016-06-14 02:57:19 +00:00
|
|
|
|
|
|
|
Initialize a Swarm cluster. The docker engine targeted by this command becomes a manager
|
|
|
|
in the newly created one node Swarm cluster.
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker swarm init --listen-addr 192.168.99.121:2377
|
2016-07-05 22:39:26 +00:00
|
|
|
No --secret provided. Generated random secret:
|
|
|
|
4ao565v9jsuogtq5t8s379ulb
|
|
|
|
|
2016-06-17 20:30:17 +00:00
|
|
|
Swarm initialized: current node (1ujecd0j9n3ro9i6628smdmth) is now a manager.
|
2016-07-05 22:39:26 +00:00
|
|
|
|
|
|
|
To add a worker to this swarm, run the following command:
|
|
|
|
docker swarm join --secret 4ao565v9jsuogtq5t8s379ulb \
|
|
|
|
--ca-hash sha256:07ce22bd1a7619f2adc0d63bd110479a170e7c4e69df05b67a1aa2705c88ef09 \
|
|
|
|
192.168.99.121:2377
|
2016-06-14 02:57:19 +00:00
|
|
|
$ docker node ls
|
2016-07-07 03:23:53 +00:00
|
|
|
ID HOSTNAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS LEADER
|
2016-06-17 20:30:17 +00:00
|
|
|
1ujecd0j9n3ro9i6628smdmth * manager1 Accepted Ready Active Reachable Yes
|
2016-06-14 02:57:19 +00:00
|
|
|
```
|
|
|
|
|
2016-07-05 22:39:26 +00:00
|
|
|
If a secret for joining new nodes is not provided with `--secret`, `docker swarm init` will
|
|
|
|
generate a random one and print it to the terminal (as seen in the example above). To initialize
|
|
|
|
a swarm with no secret, use `--secret ""`.
|
|
|
|
|
2016-06-30 23:07:25 +00:00
|
|
|
### `--auto-accept value`
|
2016-06-14 02:57:19 +00:00
|
|
|
|
2016-07-01 23:52:33 +00:00
|
|
|
This flag controls node acceptance into the cluster. By default, `worker` nodes are
|
2016-07-03 17:58:11 +00:00
|
|
|
automatically accepted by the cluster. This can be changed by specifying what kinds of nodes
|
2016-06-17 20:30:17 +00:00
|
|
|
can be auto-accepted into the cluster. If auto-accept is not turned on, then
|
2016-06-14 02:57:19 +00:00
|
|
|
[node accept](node_accept.md) can be used to explicitly accept a node into the cluster.
|
|
|
|
|
|
|
|
For example, the following initializes a cluster with auto-acceptance of workers, but not managers
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker swarm init --listen-addr 192.168.99.121:2377 --auto-accept worker
|
|
|
|
```
|
|
|
|
|
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`
|
|
|
|
|
|
|
|
The node listens for inbound Swarm manager traffic on this IP:PORT
|
|
|
|
|
|
|
|
### `--secret string`
|
|
|
|
|
|
|
|
Secret value needed to accept nodes into the Swarm
|
|
|
|
|
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)
|