blob: 1d53eff296344f9e225113129b35cf3b0102384c (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 | <h1>Add nodes to the swarm</h1>
<p>Once you’ve <a href="../create-swarm/index">created a swarm</a> with a manager node, you’re ready to add worker nodes.</p> <ol> <li> <p>Open a terminal and ssh into the machine where you want to run a worker node. This tutorial uses the name <code class="language-plaintext highlighter-rouge">worker1</code>.</p> </li> <li> <p>Run the command produced by the <code class="language-plaintext highlighter-rouge">docker swarm init</code> output from the <a href="../create-swarm/index">Create a swarm</a> tutorial step to create a worker node joined to the existing swarm:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker swarm join \
  --token  SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
  192.168.99.100:2377
This node joined a swarm as a worker.
</pre></div>  <p>If you don’t have the command available, you can run the following command on a manager node to retrieve the join command for a worker:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker swarm join-token worker
To add a worker to this swarm, run the following command:
    docker swarm join \
    --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
    192.168.99.100:2377
</pre></div>  </li> <li> <p>Open a terminal and ssh into the machine where you want to run a second worker node. This tutorial uses the name <code class="language-plaintext highlighter-rouge">worker2</code>.</p> </li> <li> <p>Run the command produced by the <code class="language-plaintext highlighter-rouge">docker swarm init</code> output from the <a href="../create-swarm/index">Create a swarm</a> tutorial step to create a second worker node joined to the existing swarm:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker swarm join \
  --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
  192.168.99.100:2377
This node joined a swarm as a worker.
</pre></div>  </li> <li> <p>Open a terminal and ssh into the machine where the manager node runs and run the <code class="language-plaintext highlighter-rouge">docker node ls</code> command to see the worker nodes:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker node ls
ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
03g1y59jwfg7cf99w4lt0f662    worker2   Ready   Active
9j68exjopxe7wfl6yuxml7a7j    worker1   Ready   Active
dxn1zf6l61qsb1josjja83ngz *  manager1  Ready   Active        Leader
</pre></div>  <p>The <code class="language-plaintext highlighter-rouge">MANAGER</code> column identifies the manager nodes in the swarm. The empty status in this column for <code class="language-plaintext highlighter-rouge">worker1</code> and <code class="language-plaintext highlighter-rouge">worker2</code> identifies them as worker nodes.</p> <p>Swarm management commands like <code class="language-plaintext highlighter-rouge">docker node ls</code> only work on manager nodes.</p> </li> </ol> <h2 id="whats-next">What’s next?</h2> <p>Now your swarm consists of a manager and two worker nodes. In the next step of the tutorial, you <a href="../deploy-service/index">deploy a service</a> to the swarm.</p> 
<p><a href="https://docs.docker.com/search/?q=tutorial">tutorial</a>, <a href="https://docs.docker.com/search/?q=cluster%20management">cluster management</a>, <a href="https://docs.docker.com/search/?q=swarm">swarm</a></p>
<div class="_attribution">
  <p class="_attribution-p">
    © 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
    <a href="https://docs.docker.com/engine/swarm/swarm-tutorial/add-nodes/" class="_attribution-link">https://docs.docker.com/engine/swarm/swarm-tutorial/add-nodes/</a>
  </p>
</div>
 |