Answers: <p>The swarm protocol is not http, so you will not be able to pass it through a proxy. Swarm nodes need direct communication between each node on port 2377/tcp (or your configured swarm port), 7946/both, and 4789/udp. If you configure an overlay network with the secure option for IPSec, then you'll also need protocol 50 open between the nodes.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-05-24T18:11:52.517Z
Answers: i have updated my caddy config to not specify port number. i then opened up port `7946` and `4789`. port `50` is not required as i am not using an `overlay` network. i then ran the command: `sudo docker swarm join --token <some-long-hash> swarm.mydomain.com:2377`. the domain name will forward all traffic to the node where the ports mentioned are open on both nodes. i get the same error: `Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable`. im sure my setup is not normal, but im quite new to devops so i dont know if this is this even possible?
Answers: X0r0N
Answers: CC BY-SA 4.0
Answers: 2018-05-24T18:15:27.370Z
Answers: Stop using the proxy, do not run your join to the hostname pointing to caddy. Do the join directly to the manager ip, which gets output by docker when you request the join token. Changing the command docker gives you is causing your errors.
Answers: BMitch
Answers: CC BY-SA 4.0
Answers: 2018-05-24T19:20:03.163Z
Answers: the manager is in a private network and the node i am trying to connect is connecting over the internet. this is why i am trying to proxy the connection. if it was possible to initialise a swarm token with specifying a domain, then this would work. it seems docker swarm will not allow swarm join token by domain name. this is not a common or secure use-case, but this feature may be at least be useful for some people like me who are trying to learn devops.
Answers: X0r0N
Answers: CC BY-SA 4.0
Answers: 2018-05-24T20:46:44.967Z
Answers: If you need to connect to a non-internet accessable system, then a vpn may be the best option. A proxy will not work.
Answers: BMitch
Answers: CC BY-SA 4.0
Answers: 2018-05-24T16:51:24.720Z
Answers: 2018-05-24T16:51:24.720Z
Answers: BMitch
Body: <p>I am trying to add a new node into my swarm over the internet but it doesn't seem to connect through a proxy.</p>
  
  <p>I am trying to proxy using <a href="https://caddyserver.com/docs" rel="nofollow noreferrer">Caddy</a>. The proxy configuration results in the same as for any other server like proxy_pass in nginx.</p>
  
  <p>Caddy automatically sets up HTTPS for the subdomain and all traffic is set to be redirected from port 80 to 443. My caddy configuration is:</p>
  
  <pre><code>swarm.mydomain.com {
      proxy / http://&lt;docker-swarm-manager-ip&gt;:2377 {
          transparent
      }
  }
  </code></pre>
  
  <p>From the docker swarm manager, I get the join-token which gives me something like:</p>
  
  <pre><code>docker swarm join --token &lt;some-long-hash&gt; &lt;docker-swarm-manager-ip&gt;:2377
  </code></pre>
  
  <p>On the node I want to connect to the swarm, I have tried the command:</p>
  
  <pre><code>sudo docker swarm join --token &lt;some-long-hash&gt; swarm.mydomain.com
  </code></pre>
  
  <p>This gives me the error:</p>
  
  <blockquote>
    <p>Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable</p>
  </blockquote>
  
  <p>I then tried specifying the SSL port:</p>
  
  <pre><code>sudo docker swarm join --token &lt;some-long-hash&gt; swarm.mydomain.com:443
  </code></pre>
  
  <p>This gives me the error:</p>
  
  <blockquote>
    <p>Error response from daemon: rpc error: code = FailedPrecondition desc = transport: received the unexpected content-type "text/plain; charset=utf-8"</p>
  </blockquote>
  
  <p>I am new to docker swarm and I can't find any similar setup online. Any help is appreciated.</p>
  
  <p><strong>Note:</strong></p>
  
  <ul>
  <li>I am able to ping the manager from the node successfully.</li>
  <li>port 2377 is is open on the manager and the node I want to connect.</li>
  </ul>
  
Tags: <docker><docker-swarm>
Title: Docker Swarm join-token not working
UserDisplayName: X0r0N
ThreadText: # Docker Swarm join-token not working
  
  (Asked by: username_0 on 2018-05-23)
  
  I am trying to add a new node into my swarm over the internet but it doesn't seem to connect through a proxy.
  
  I am trying to proxy using [Caddy](https://caddyserver.com/docs). The proxy configuration results in the same as for any other server like proxy\_pass in nginx.
  
  Caddy automatically sets up HTTPS for the subdomain and all traffic is set to be redirected from port 80 to 443. My caddy configuration is:
  
  ```
  swarm.mydomain.com {
      proxy / http://<docker-swarm-manager-ip>:2377 {
          transparent
      }
  }
  
  ```
  
  From the docker swarm manager, I get the join-token which gives me something like:
  
  ```
  docker swarm join --token <some-long-hash> <docker-swarm-manager-ip>:2377
  
  ```
  
  On the node I want to connect to the swarm, I have tried the command:
  
  ```
  sudo docker swarm join --token <some-long-hash> swarm.mydomain.com
  
  ```
  
  This gives me the error:
  
  > Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable
  
  I then tried specifying the SSL port:
  
  ```
  sudo docker swarm join --token <some-long-hash> swarm.mydomain.com:443
  
  ```
  
  This gives me the error:
  
  > Error response from daemon: rpc error: code = FailedPrecondition desc = transport: received the unexpected content-type "text/plain; charset=utf-8"
  
  I am new to docker swarm and I can't find any similar setup online. Any help is appreciated.
  
  **Note:**
  
  * I am able to ping the manager from the node successfully.
  * port 2377 is is open on the manager and the node I want to connect.
  
  **Tags:** docker, docker-swarm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-24. Score: 2
  
  The swarm protocol is not http, so you will not be able to pass it through a proxy. Swarm nodes need direct communication between each node on port 2377/tcp (or your configured swarm port), 7946/both, and 4789/udp. If you configure an overlay network with the secure option for IPSec, then you'll also need protocol 50 open between the nodes.
  
  > **Comments:**
  > **username_0**: i have updated my caddy config to not specify port number. i then opened up port `7946` and `4789`. port `50` is not required as i am not using an `overlay` network. i then ran the command: `sudo docker swarm join --token <some-long-hash> swarm.mydomain.com:2377`. the domain name will forward all traffic to the node where the ports mentioned are open on both nodes. i get the same error: `Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable`. im sure my setup is not normal, but im quite new to devops so i dont know if this is this even possible?  
  > **username_1**: Stop using the proxy, do not run your join to the hostname pointing to caddy. Do the join directly to the manager ip, which gets output by docker when you request the join token. Changing the command docker gives you is causing your errors.  
  > **username_0**: the manager is in a private network and the node i am trying to connect is connecting over the internet. this is why i am trying to proxy the connection. if it was possible to initialise a swarm token with specifying a domain, then this would work. it seems docker swarm will not allow swarm join token by domain name. this is not a common or secure use-case, but this feature may be at least be useful for some people like me who are trying to learn devops.  
  > **username_1**: If you need to connect to a non-internet accessable system, then a vpn may be the best option. A proxy will not work.  
  
  ---
  
  