0

I'm having troubles to find which advertise address the manager should use to work with the following setup:

Server setup

The problem is that if I use the default options of docker swarm init on the host, I can't get my docker machine to connect to this swarm using the connection string returned by the init above.

user@host$ docker swarm init
Swarm initialized: current node (9cv0khu88hdq7wsdqlzqpj7e0) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-2qx019269giy7jsnehqukpgjz9pqfe7ifprd0evcyi3ef1d699-7c1jig60by75lpuh5pjg5wuy8 192.168.65.2:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

user@host$ docker-machine ssh my-vm-1
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.10.0-ce, build HEAD : 34fe485 - Wed Oct 18 17:16:34 UTC 2017
Docker version 17.10.0-ce, build f4ffd25
docker@my-vm-1$ docker swarm join --token SWMTKN-1-2qx019269giy7jsnehqukpgjz9pqfe7ifprd0evcyi3ef1d699-7c1jig60by75lpuh5pjg5wuy8 192.168.65.2:2377

Error response from daemon: Timeout was reached before node joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node.

Okay, this is probably dumb to hope that it will work without any options but... How am I supposed to know which interface my swarm's manager should listen?

Thank you for your time, have a nice day

Alex

Footnote: I've posted the same question on Docker Community

1 Answers1

0

According to your setup, when you create a docker VM with docker-machine you will have a new vboxnet interface with a 192.168.99.1 IP address:

7: vboxnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 0a:00:27:00:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.99.1/24 brd 192.168.99.255 scope global vboxnet1
       valid_lft forever preferred_lft forever

In your docker-machine VM that network will be configured in your eth1 interface:

4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:f0:26:ac brd ff:ff:ff:ff:ff:ff
    inet 192.168.99.100/24 brd 192.168.99.255 scope global eth1

That network address 192.168.99.0/24 is the one you can use to communicate your host with the docker-machine VM.

In your host start your swarm with the host IP:

docker swarm init --advertise-addr 192.168.99.1

And in your docker-machine use the token to join the swarm:

docker swarm join --token SWMTKN-1-5rzst....4onvjsdpvnc23ya4tq7zdrjjw 192.168.99.1:2377
This node joined a swarm as a worker.

And your docker swarm will have two nodes.

Miguel A. C.
  • 1,366
  • 11
  • 12
  • Nice, I didn't saw that network. But it still does not work: `Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable` But this is probably a different problem... I'll accept your answer as soon as it works – Alexandre Germain Nov 18 '17 at 16:18
  • 1
    I think that this problem is related with a firewall running in your host machine that prevents your node joining the swarm. Maybe you can disable your firewall temporarily or add some rules allowing these ports: 2377/TCP, 7946/TCP, 7946/UDP and 4789/UDP. You may find this [link](https://docs.docker.com/engine/swarm/swarm-tutorial/#the-ip-address-of-the-manager-machine) and this [link](https://github.com/moby/moby/issues/24078) useful. – Miguel A. C. Nov 19 '17 at 10:38
  • Unfortunately, my firewall is already disabled... Maybe this problem occurs on OSx only, I've never get the swarm to work on it. I'll give it a try on my CentOS server ASAP. Keep you in touch ;) cheers – Alexandre Germain Nov 19 '17 at 13:43
  • Oh, too bad I don't have a Mac to test and I should have read the docs first :) There is some kind of problem with [Mac](https://docs.docker.com/engine/swarm/swarm-tutorial/#use-docker-for-mac-or-docker-for-windows) "but that Docker host itself is not participating in the swarm" it's the key, next time I'll ask first about the platform. So then use only docker-machine VMs in your Mac laptop or as already suggested with CentOS you can use your host too. – Miguel A. C. Nov 20 '17 at 07:57