Answers: <p>Why do you want to create a new Manager node, risking damaging your raft consensus and cie?</p>
  <p>I find it way easier to simply expose the <strong>docker socket</strong> locally, as if you were working inside the node, but with your Windows environment.</p>
  <p>To do so, simply open a <strong>ssh tunnel</strong> that exposes <code>/var/run/docker.sock</code>:</p>
  <pre><code> ssh -M -S ~/.docker.sock \
       -fnNT -4 -L localhost:1337:/var/run/docker.sock \
       USER@MANAGER_IP
  </code></pre>
  <p>Refer to <code>man ssh</code> to see what all these options mean.</p>
  <p>It will open an ssh tunnel; you will still be in your local environment shell, only thing left to do is set the proper <code>DOCKER_HOST</code> environment var, so your docker cli is bound to your swarm manager.</p>
  <p><code>export DOCKER_HOST=localhost:1337</code></p>
  <p>And that's it.</p>
  <p>Note: Docker also includes an option to do this; I've quickly searched for it but can't manage to find it. It's in the most recent version of docker.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-04-26T08:32:53.560Z
Answers: 2020-10-26T18:34:57.493Z
Answers: 2020-10-26T18:34:57.493Z
Answers: Juub
Answers: <p>You cannot mix docker engine versions on the swarm managers. They need to each be running the same version, particularly when adding, removing, promoting, and demoting nodes. When you need to upgrade the engine on the managers, you can upgrade the engines in place, without promote/demote, but I would strive to minimize the time in this state and avoid using any newer features in the swarm.</p>
  
  <p>Adding a second manager to a cluster is also not recommended. Should any issue occur, like the problem you're currently experiencing, you will lose quorum with only a single manager running. In effect, you've doubled the potential points of failure rather than creating an HA infrastructure. With quorum, you do need at least 3 nodes to be managers to have the ability to lose a single node. It's best to do this to an existing cluster by adding the additional managers first as workers, and then after you verify connectivity, promoting those nodes to managers.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-05-24T20:21:24.380Z
Answers: Ok, thanks, I'll try to use the same version tomorrow and tell you if it does solve the problem! Thanks anyway for your answer. And I'll have 3 managers if it succeeds, 2 if it won't (so the quorum will be available). Remember that is a test cluster, for preproduction for more details, not for production. Production will have 3 real managers. That's why I allowed myself to do this "trick".
Answers: Paul Rey
Answers: CC BY-SA 4.0
Answers: 2018-05-25T08:35:56.770Z
Answers: Well, I set the same version on all my nodes. I achieved to join the cluster but I don't think that is for this reason..! I mean, I already had a manager with a different version and it worked all the way. Additionnaly, I cannot achieve to join the swarm until I set the option `--advertise-addr 192.168.0.200` - which is my leader manager address - to the `docker join` command. I feel dumb but, anyway, it seems to work... Thanks for you help @BMitch!
Answers: Paul Rey
Answers: CC BY-SA 4.0
Answers: 2018-05-24T17:01:48.617Z
Answers: 2018-05-24T17:01:48.617Z
Answers: BMitch
Body: <p>I'm currenlty trying to connect/join a Linux Docker Swarm cluster with my Windows machine in order to test a stack without sending the stack over and over to my test cluster under Linux. My problem is that I can't join the cluster with my Windows Docker.</p>
  
  <p>My cluster had initially 1 manager and 4 workers. I recently created and added a new manager to it in order to add my Windows Docker node as manager. With this, I shouldn't have any issue with the manager quorum (since my two managers will be always up, and my Windows Docker could be interrupted at any time).</p>
  
  <p>I configured my local firewall - and also on each nodes of my Linux cluster - to accept connections on ports (the following can be found at the end of <a href="https://docs.docker.com/engine/swarm/swarm-tutorial/" rel="nofollow noreferrer">this documentation</a>) :</p>
  
  <ul>
  <li>TCP port 2377 for cluster management communications</li>
  <li>TCP and UDP port 7946 for communication among nodes</li>
  <li>UDP port 4789 for overlay network traffic</li>
  </ul>
  
  <p>The advertising network in my cluster is <code>192.168.0.0/24</code>, one of my manager's IP address is <code>192.168.0.100</code> and my PC's IP address is <code>192.168.0.143</code> (same network). They can ping each others and I tested the ports defined before.</p>
  
  <p>So, when I perform the <code>docker swarm join-token manager</code> on a manager I have something like this:</p>
  
  <pre><code>docker swarm join --token SWMTKN-1-27hzpcnek5... 192.168.0.200:2377
  </code></pre>
  
  <p>If I copy/paste it to my PC:</p>
  
  <pre><code>Error response from daemon: manager stopped: can't initialize raft node: rpc error: code = Unknown desc = could not connect to prospective new cluster member using its advertised address: rpc error: code = DeadlineExceeded desc = context deadline exceeded
  </code></pre>
  
  <p>But, even with this error, on my cluster, if I run <code>docker node ls</code>, my node appears in the list:</p>
  
  <pre><code>8380zb5jeke0elwohr7aieke8     linuxkit-00155d00d946   Ready               Active
  </code></pre>
  
  <p>But on my PC Docker thinks that it's not member of a cluster:</p>
  
  <pre><code>Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.
  </code></pre>
  
  <p>The Docker version is different in the cluster and on my PC:</p>
  
  <ul>
  <li>Cluster:
  
  <ul>
  <li>Client: <code>17.09.1-ce</code></li>
  <li>Server: <code>17.09.1-ce</code></li>
  </ul></li>
  <li>PC:
  
  <ul>
  <li>Client: <code>18.03.1-ce</code></li>
  <li>Server: <code>18.03.1-ce</code></li>
  </ul></li>
  </ul>
  
  <p>Could the issue came from this?</p>
  
  <p>N.B.: I work with Bash on Ubuntu on Windows, but the result is the same on PowerShell.</p>
  
  <p>N.B. 2: I don't know if it's useful, but since Docker for Windows uses Hyper-V, I have a NAT interface: <code>10.0.75.0/24</code> (and the VM's IP address is <code>10.0.75.1</code>). I tried to use this interface as advertising address and listening address but the issue returned is the same   </p>
  
  <p>Does anybody already encounter this issue? Any ideas?</p>
  
  <p>Thanks! :)</p>
  
  <p><strong>EDIT 1:</strong> </p>
  
  <p>Disaggreeing with @BMitch's answer, after tests, I don't think there is any issue with the difference between managers' Docker versions.</p>
  
  <p>As I said in <a href="https://devops.stackexchange.com/questions/4161/join-a-linux-docker-swarm-with-a-local-windows-docker-for-test-purposes/4165#comment5972_4165">my previous comment on BMitch's answer</a>, I had to add the option <code>--advertise-addr 192.168.0.200</code> - which is my leader manager address - to the docker join command. Until this, I used <code>--advertise-addr 192.168.0.143</code>, my PC address.</p>
  
  <p>I hope it will help others.</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>If I run <code>docker info</code> on my PC I got this:</p>
  
  <pre><code>Swarm: active
   NodeID: o9wehjcyhe3n6xxzy1epnhxdp
   Error: rpc error: code = Unknown desc = The swarm does not have a leader. It's possible that too few managers are online. Make sure more than half of the managers are online.
   Is Manager: true
   Node Address: 192.168.0.200
   Manager Addresses:
    192.168.0.200:2377
    192.168.0.200:2377
    192.168.0.201:2377
  </code></pre>
  
  <p>There are two managers with address <code>192.168.0.200:2377</code>.</p>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>I finally gave up and installed a Linux server on another machine in order to join the cluster. That's not what I wanted but I can work now.</p>
  
  <p>If any have information about this issue, I invite you to share it. Thanks :)</p>
  
Comments: CC BY-SA 4.0
Comments: 2018-05-24T15:50:18.410Z
Comments: It seems that other persons have the same issue: https://stackoverflow.com/questions/47706008/run-docker-swarm-mode-on-windows-10-using-multiple-hosts but no answer yet.
Comments: Paul Rey
Tags: <docker><windows><linux><docker-swarm><networking>
Title: Join a Linux Docker swarm with a local Windows Docker for test purposes
UserDisplayName: Paul Rey
ThreadText: # Join a Linux Docker swarm with a local Windows Docker for test purposes
  
  (Asked by: username_0 on 2018-05-24)
  
  I'm currenlty trying to connect/join a Linux Docker Swarm cluster with my Windows machine in order to test a stack without sending the stack over and over to my test cluster under Linux. My problem is that I can't join the cluster with my Windows Docker.
  
  My cluster had initially 1 manager and 4 workers. I recently created and added a new manager to it in order to add my Windows Docker node as manager. With this, I shouldn't have any issue with the manager quorum (since my two managers will be always up, and my Windows Docker could be interrupted at any time).
  
  I configured my local firewall - and also on each nodes of my Linux cluster - to accept connections on ports (the following can be found at the end of [this documentation](https://docs.docker.com/engine/swarm/swarm-tutorial/)) :
  
  * TCP port 2377 for cluster management communications
  * TCP and UDP port 7946 for communication among nodes
  * UDP port 4789 for overlay network traffic
  
  The advertising network in my cluster is `192.168.0.0/24`, one of my manager's IP address is `192.168.0.100` and my PC's IP address is `192.168.0.143` (same network). They can ping each others and I tested the ports defined before.
  
  So, when I perform the `docker swarm join-token manager` on a manager I have something like this:
  
  ```
  docker swarm join --token SWMTKN-1-27hzpcnek5... 192.168.0.200:2377
  
  ```
  
  If I copy/paste it to my PC:
  
  ```
  Error response from daemon: manager stopped: can't initialize raft node: rpc error: code = Unknown desc = could not connect to prospective new cluster member using its advertised address: rpc error: code = DeadlineExceeded desc = context deadline exceeded
  
  ```
  
  But, even with this error, on my cluster, if I run `docker node ls`, my node appears in the list:
  
  ```
  8380zb5jeke0elwohr7aieke8     linuxkit-00155d00d946   Ready               Active
  
  ```
  
  But on my PC Docker thinks that it's not member of a cluster:
  
  ```
  Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.
  
  ```
  
  The Docker version is different in the cluster and on my PC:
  
  * Cluster:
    + Client: `17.09.1-ce`
    + Server: `17.09.1-ce`
  * PC:
    + Client: `18.03.1-ce`
    + Server: `18.03.1-ce`
  
  Could the issue came from this?
  
  N.B.: I work with Bash on Ubuntu on Windows, but the result is the same on PowerShell.
  
  N.B. 2: I don't know if it's useful, but since Docker for Windows uses Hyper-V, I have a NAT interface: `10.0.75.0/24` (and the VM's IP address is `10.0.75.1`). I tried to use this interface as advertising address and listening address but the issue returned is the same
  
  Does anybody already encounter this issue? Any ideas?
  
  Thanks! :)
  
  **EDIT 1:**
  
  Disaggreeing with @username_2's answer, after tests, I don't think there is any issue with the difference between managers' Docker versions.
  
  As I said in [my previous comment on username_2's answer](https://devops.stackexchange.com/questions/4161/join-a-linux-docker-swarm-with-a-local-windows-docker-for-test-purposes/4165#comment5972_4165), I had to add the option `--advertise-addr 192.168.0.200` - which is my leader manager address - to the docker join command. Until this, I used `--advertise-addr 192.168.0.143`, my PC address.
  
  I hope it will help others.
  
  **EDIT 2:**
  
  If I run `docker info` on my PC I got this:
  
  ```
  Swarm: active
   NodeID: o9wehjcyhe3n6xxzy1epnhxdp
   Error: rpc error: code = Unknown desc = The swarm does not have a leader. It's possible that too few managers are online. Make sure more than half of the managers are online.
   Is Manager: true
   Node Address: 192.168.0.200
   Manager Addresses:
    192.168.0.200:2377
    192.168.0.200:2377
    192.168.0.201:2377
  
  ```
  
  There are two managers with address `192.168.0.200:2377`.
  
  **EDIT 3:**
  
  I finally gave up and installed a Linux server on another machine in order to join the cluster. That's not what I wanted but I can work now.
  
  If any have information about this issue, I invite you to share it. Thanks :)
  
  **Tags:** docker, windows, linux, docker-swarm, networking
  
  > **Comments:**
  > **username_0**: It seems that other persons have the same issue: https://stackoverflow.com/questions/47706008/run-docker-swarm-mode-on-windows-10-using-multiple-hosts but no answer yet.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-04-26. Score: 2 | Accepted answer
  
  Why do you want to create a new Manager node, risking damaging your raft consensus and cie?
  
  I find it way easier to simply expose the **docker socket** locally, as if you were working inside the node, but with your Windows environment.
  
  To do so, simply open a **ssh tunnel** that exposes `/var/run/docker.sock`:
  
  ```
   ssh -M -S ~/.docker.sock \
       -fnNT -4 -L localhost:1337:/var/run/docker.sock \
       USER@MANAGER_IP
  
  ```
  
  Refer to `man ssh` to see what all these options mean.
  
  It will open an ssh tunnel; you will still be in your local environment shell, only thing left to do is set the proper `DOCKER_HOST` environment var, so your docker cli is bound to your swarm manager.
  
  `export DOCKER_HOST=localhost:1337`
  
  And that's it.
  
  Note: Docker also includes an option to do this; I've quickly searched for it but can't manage to find it. It's in the most recent version of docker.
  
  
  ---
  
  ### Answer by username_2 on 2018-05-24. Score: 0
  
  You cannot mix docker engine versions on the swarm managers. They need to each be running the same version, particularly when adding, removing, promoting, and demoting nodes. When you need to upgrade the engine on the managers, you can upgrade the engines in place, without promote/demote, but I would strive to minimize the time in this state and avoid using any newer features in the swarm.
  
  Adding a second manager to a cluster is also not recommended. Should any issue occur, like the problem you're currently experiencing, you will lose quorum with only a single manager running. In effect, you've doubled the potential points of failure rather than creating an HA infrastructure. With quorum, you do need at least 3 nodes to be managers to have the ability to lose a single node. It's best to do this to an existing cluster by adding the additional managers first as workers, and then after you verify connectivity, promoting those nodes to managers.
  
  > **Comments:**
  > **username_0**: Ok, thanks, I'll try to use the same version tomorrow and tell you if it does solve the problem! Thanks anyway for your answer. And I'll have 3 managers if it succeeds, 2 if it won't (so the quorum will be available). Remember that is a test cluster, for preproduction for more details, not for production. Production will have 3 real managers. That's why I allowed myself to do this "trick".  
  > **username_0**: Well, I set the same version on all my nodes. I achieved to join the cluster but I don't think that is for this reason..! I mean, I already had a manager with a different version and it worked all the way. Additionnaly, I cannot achieve to join the swarm until I set the option `--advertise-addr 192.168.0.200` - which is my leader manager address - to the `docker join` command. I feel dumb but, anyway, it seems to work... Thanks for you help @username_2!  
  
  ---
  
  