7

I've been trying to follow this tutorial: https://docs.docker.com/engine/swarm/swarm-tutorial/

Instead of running it on some real linux hosts or local VMs I want to network a couple of MacBooks running Docker desktop for Mac.

Following the tutorial I've installed Docker desktop for Mac on two machines. In a terminal on the first machine docker swarm create works and creates a ca hash and id.

Carrying on to the second machine I execute the join command by pasting it from one to the other.

The second machine cannot connect. This is expected since the IP address show in the output is clearly the IP address inside the virtual machine and not an address on my machine. I tried diverting from the tutorial by specifying the address of the local network adaptor but it says it cannot bind to that address. I know all the ports are open and the machine can connect to each other.

So it seems to me I'm fundamentally misunderstanding the aim of the tutorial or how to setup the two Macs so they can communicate. By googling for solutions it seems there are several possibilities for what I need to do:

Run a distributed kv store to help the swarm network coordinate (but isn't this the point of the new orchestration?) Set up a port tunnel on each machine from the network adaptor to the alpine linux docker daemon Give up and just test my cluster locally

Update: after some more research it seems I should create an overlay network using this guide. But this guide uses docker-machine. As far as I understand I should/can not use docker-machine along with Docker desktop for Mac, or is that incorrect?

https://docs.docker.com/engine/userguide/networking/get-started-overlay/

veben
  • 19,637
  • 14
  • 60
  • 80
justinhj
  • 11,147
  • 11
  • 58
  • 104

3 Answers3

4

You have to set up a port tunnel to promote the docker daemon port inside the VM to the hosts network interface. To check if you can reach the daemon of another machine use https://otherMachineIp:DaemonPort/v1/_ping. If this succedes you can reach the other daemon to set up a swarm.

BTW as long as you are on the same docker version, using Docker for Mac and docker-machine together should not cause problems.

Ohmen
  • 6,194
  • 3
  • 25
  • 35
0

But this guide uses docker-machine.

That should not be an issue: each time you see in the tutorial

Point your environment to the Swarm master.

$ eval $(docker-machine env --swarm mhs-demo0)

It simply means you are supposed to execute the next docker command on the swarm master (one of your mac)

Switch to each Swarm agent in turn and list the networks.

$ eval $(docker-machine env mhs-demo0)

Similarly, you switch to your other mac to execute other docker commands.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This is the main point of confusion for me. When using Docker for Mac, docker-machine knows nothing of the docker host running on the hypervisor. So "docker-machine env" returns an error because the host is not running. – justinhj Jul 25 '16 at 16:29
  • My point was: each time you see docker-machine, do not use docker-machine, but directly docker commands on the right (physical) machine – VonC Jul 25 '16 at 16:30
0

As of Docker 1.12 this is not possible. It may be worked on in a later version.

justinhj
  • 11,147
  • 11
  • 58
  • 104