update create swarm and add nodes to use the auto-generated join command
| ... | ... |
@@ -19,34 +19,41 @@ to add worker nodes. |
| 19 | 19 |
1. Open a terminal and ssh into the machine where you want to run a worker node. |
| 20 | 20 |
This tutorial uses the name `worker1`. |
| 21 | 21 |
|
| 22 |
-2. Run the following command to create a worker node joined to |
|
| 23 |
-the existing swarm: |
|
| 22 |
+2. Run the command produced by the `docker swarm init` output from the |
|
| 23 |
+[Create a swarm](create-swarm.md) tutorial step to create a worker node joined to the existing swarm: |
|
| 24 | 24 |
|
| 25 |
- ``` |
|
| 26 |
- docker swarm join --secret <SECRET> <MANAGER-IP>:<PORT> |
|
| 25 |
+ ```bash |
|
| 26 |
+ $ docker swarm join --secret 4ao565v9jsuogtq5t8s379ulb \ |
|
| 27 |
+ --ca-hash sha256:07ce22bd1a7619f2adc0d63bd110479a170e7c4e69df05b67a1aa2705c88ef09 \ |
|
| 28 |
+ 192.168.99.100:2377 |
|
| 27 | 29 |
``` |
| 28 | 30 |
|
| 29 |
- Replace `<SECRET>` with the secret that was printed by `docker swarm init` in the |
|
| 30 |
- previous step. Replace `<MANAGER-IP>` with the address of the manager node |
|
| 31 |
- and `<PORT>` with the port where the manager listens. |
|
| 32 |
- |
|
| 33 |
- In the tutorial, the following command joins `worker1` to the swarm on `manager1`: |
|
| 31 |
+ If you don't have the command available, you can run the following command: |
|
| 34 | 32 |
|
| 33 |
+ ```bash |
|
| 34 |
+ docker swarm join --secret <SECRET> <MANAGER-IP>:<PORT> |
|
| 35 | 35 |
``` |
| 36 |
- $ docker swarm join --secret 4ao565v9jsuogtq5t8s379ulb 192.168.99.100:2377 |
|
| 37 | 36 |
|
| 38 |
- This node joined a Swarm as a worker. |
|
| 39 |
- ``` |
|
| 37 |
+ Replace `<SECRET>` with the secret that was printed by `docker swarm init` |
|
| 38 |
+ in the previous step. Replace `<MANAGER-IP>` with the address of the manager |
|
| 39 |
+ node and `<PORT>` with the port where the manager listens. |
|
| 40 |
+ |
|
| 41 |
+ The command generated from `docker swarm init` includes the `--ca-hash` to |
|
| 42 |
+ securely identify the manager node according to its root CA. For the |
|
| 43 |
+ tutorial, it is OK to join without it. |
|
| 40 | 44 |
|
| 41 | 45 |
3. Open a terminal and ssh into the machine where you want to run a second |
| 42 | 46 |
worker node. This tutorial uses the name `worker2`. |
| 43 | 47 |
|
| 44 |
-4. Run `docker swarm join --secret <SECRET> <MANAGER-IP>:<PORT>` to create a worker node joined to |
|
| 45 |
-the existing Swarm. |
|
| 48 |
+4. Run the command produced by the `docker swarm init` output from the |
|
| 49 |
+[Create a swarm](create-swarm.md) tutorial step to create a second worker node |
|
| 50 |
+joined to the existing swarm: |
|
| 46 | 51 |
|
| 47 |
- Replace `<SECRET>` with the secret that was printed by `docker swarm init` in the |
|
| 48 |
- previous step. Replace `<MANAGER-IP>` with the address of the manager node |
|
| 49 |
- and `<PORT>` with the port where the manager listens. |
|
| 52 |
+ ```bash |
|
| 53 |
+ $ docker swarm join --secret 4ao565v9jsuogtq5t8s379ulb \ |
|
| 54 |
+ --ca-hash sha256:07ce22bd1a7619f2adc0d63bd110479a170e7c4e69df05b67a1aa2705c88ef09 \ |
|
| 55 |
+ 192.168.99.100:2377 |
|
| 56 |
+ ``` |
|
| 50 | 57 |
|
| 51 | 58 |
5. Open a terminal and ssh into the machine where the manager node runs and run |
| 52 | 59 |
the `docker node ls` command to see the worker nodes: |
| ... | ... |
@@ -22,51 +22,59 @@ node. For example, the tutorial uses a machine named `manager1`. |
| 22 | 22 |
|
| 23 | 23 |
2. Run the following command to create a new swarm: |
| 24 | 24 |
|
| 25 |
- ``` |
|
| 25 |
+ ```bash |
|
| 26 | 26 |
docker swarm init --listen-addr <MANAGER-IP>:<PORT> |
| 27 | 27 |
``` |
| 28 | 28 |
|
| 29 |
- In the tutorial, the following command creates a swarm on the `manager1` machine: |
|
| 29 |
+ In the tutorial, the following command creates a swarm on the `manager1` |
|
| 30 |
+ machine: |
|
| 30 | 31 |
|
| 31 |
- ``` |
|
| 32 |
+ ```bash |
|
| 32 | 33 |
$ docker swarm init --listen-addr 192.168.99.100:2377 |
| 33 | 34 |
No --secret provided. Generated random secret: |
| 34 |
- 4ao565v9jsuogtq5t8s379ulb |
|
| 35 |
+ 4ao565v9jsuogtq5t8s379ulb |
|
| 35 | 36 |
|
| 36 |
- Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager. |
|
| 37 |
+ Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a |
|
| 38 |
+ manager. |
|
| 37 | 39 |
|
| 38 | 40 |
To add a worker to this swarm, run the following command: |
| 39 |
- docker swarm join --secret 4ao565v9jsuogtq5t8s379ulb \ |
|
| 40 |
- --ca-hash sha256:07ce22bd1a7619f2adc0d63bd110479a170e7c4e69df05b67a1aa2705c88ef09 \ |
|
| 41 |
- 192.168.99.100:2377 |
|
| 41 |
+ docker swarm join --secret 4ao565v9jsuogtq5t8s379ulb \ |
|
| 42 |
+ --ca-hash sha256:07ce22bd1a7619f2adc0d63bd110479a170e7c4e69df05b67a1aa2705c88ef09 \ |
|
| 43 |
+ 192.168.99.100:2377 |
|
| 42 | 44 |
``` |
| 43 | 45 |
|
| 44 | 46 |
The `--listen-addr` flag configures the manager node to listen on port |
| 45 | 47 |
`2377`. The other nodes in the swarm must be able to access the manager at |
| 46 | 48 |
the IP address. |
| 47 | 49 |
|
| 50 |
+ The `--ca-hash` flag provides the identity of the root CA for the manager |
|
| 51 |
+ node. |
|
| 52 |
+ |
|
| 53 |
+2. Save the output of `docker swarm init` that includes the command to join |
|
| 54 |
+worker nodes to the swarm. |
|
| 55 |
+ |
|
| 48 | 56 |
3. Run `docker info` to view the current state of the swarm: |
| 49 | 57 |
|
| 50 |
- ``` |
|
| 51 |
- $ docker info |
|
| 58 |
+ ```bash |
|
| 59 |
+ $ docker info |
|
| 52 | 60 |
|
| 53 |
- Containers: 2 |
|
| 54 |
- Running: 0 |
|
| 55 |
- Paused: 0 |
|
| 56 |
- Stopped: 2 |
|
| 57 |
- ...snip... |
|
| 58 |
- Swarm: active |
|
| 61 |
+ Containers: 2 |
|
| 62 |
+ Running: 0 |
|
| 63 |
+ Paused: 0 |
|
| 64 |
+ Stopped: 2 |
|
| 65 |
+ ...snip... |
|
| 66 |
+ Swarm: active |
|
| 59 | 67 |
NodeID: dxn1zf6l61qsb1josjja83ngz |
| 60 | 68 |
Is Manager: true |
| 61 | 69 |
Managers: 1 |
| 62 | 70 |
Nodes: 1 |
| 63 | 71 |
CA Certificate Hash: sha256:b7986d3baeff2f5664dfe350eec32e2383539ec1a802ba541c4eb829056b5f61 |
| 64 |
- ...snip... |
|
| 65 |
- ``` |
|
| 72 |
+ ...snip... |
|
| 73 |
+ ``` |
|
| 66 | 74 |
|
| 67 | 75 |
4. Run the `docker node ls` command to view information about nodes: |
| 68 | 76 |
|
| 69 |
- ``` |
|
| 77 |
+ ```bash |
|
| 70 | 78 |
$ docker node ls |
| 71 | 79 |
|
| 72 | 80 |
ID HOSTNAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS LEADER |
| ... | ... |
@@ -74,11 +82,11 @@ node. For example, the tutorial uses a machine named `manager1`. |
| 74 | 74 |
|
| 75 | 75 |
``` |
| 76 | 76 |
|
| 77 |
- The `*` next to the node id, indicates that you're currently connected on |
|
| 78 |
- this node. |
|
| 77 |
+ The `*` next to the node id indicates that you're currently connected on |
|
| 78 |
+ this node. |
|
| 79 | 79 |
|
| 80 |
- Docker Engine swarm mode automatically names the node for the machine host |
|
| 81 |
- name. The tutorial covers other columns in later steps. |
|
| 80 |
+ Docker Engine swarm mode automatically names the node for the machine host |
|
| 81 |
+ name. The tutorial covers other columns in later steps. |
|
| 82 | 82 |
|
| 83 | 83 |
## What's next? |
| 84 | 84 |
|