Docker.github.io: Failed to join swarm as documented

Created on 29 Apr 2017  路  15Comments  路  Source: docker/docker.github.io

File: get-started/part4.md, CC @johndmulhausen

After adding the --advertise-addr argument to init the swarm on myvm1 I got the expected output:

$ docker-machine ssh myvm1 "docker swarm init --advertise-addr 192.168.99.100:2376"
Swarm initialized: current node (s8b86jmd6gi8dk9ftx07cyeop) is now a manager.

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

    docker swarm join \
    --token SWMTKN-1-0mvkhaacjfoppv7x8t6ffiue45zs2plhlsngljk08p078qis5j-eg3news5k68kgmhby38wbsyqu \
    192.168.99.100:2376

However when trying to join it from myvm2 I get the following error:

$ docker-machine ssh myvm2 "docker swarm join --token SWMTKN-1-0mvkhaacjfoppv7x8t6ffiue45zs2plhlsngljk08p078qis5j-eg3news5k68kgmhby38wbsyqu 192.168.99.100:2376"
Error response from daemon: rpc error: code = 13 desc = connection error: desc = "transport: remote error: tls: bad certificate"
exit status 1

I'm running macOS Sierra 10.12.4 on a late 2013 15" Macbook Pro with Virtualbox 5.1.20.

Docker version is:

$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true

Most helpful comment

My error! I had misunderstood that I should take the machine's IP address as last argument here, but to join the swarm one needs to specify the swarm-manager's IP, i.e. as provided in the output from the swarm init command!

I.e. the last command must be:
docker-machine ssh myvm2 "docker swarm join --token SWMTKN-1-58ibmapquculh9rd6zloubaik8avcbd4v5z8ns5906lxu7pn8b-50x2vb5oa58ti259gmvgjg4jy 192.168.1.102"
and not ... 113!

Working now!

All 15 comments

The doc says to make sure you're using port 2377: https://docs.docker.com/get-started/part4/#create-a-cluster

If you run these commands again using that port, does it work? It's not that you couldn't make it work with 2376, but I think a config change would need to happen. Let me know.

@johndmulhausen I'm cross posting my comment from here: https://github.com/docker/machine/issues/4064

It's confusing though. The tutorial is correct - port 2377 is the port that works, but while running the commands to initialise the docker swarm a user sees:

$ docker-machine ssh myvm1 "docker swarm init --advertise-addr 192.168.99.100:2376"
Swarm initialized: current node (xpjllelqsli4xk2m9f8plzzc7) is now a manager.

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

    docker swarm join \
    --token SWMTKN-1-2xw6b7rsyn5ou92rejukqvtayar3t9jz68eqd7y0m367psu7vf-dcdk4bd7lhashxx9ki460su7h \
    192.168.99.100:2376

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

Note: Port 2376

I've never worked with Go, so I could be wrong - I'm looking though the code in the cli repo and found this:

https://github.com/siliconmeadow/cli/blob/master/cli/command/swarm/join_token.go#L111

Just a heads up that I wiped my docker setup and will likely not get back to actually trying this out so can't confirm the port config theory.

Same issue, used port 2377 as instructed in the tutorial.

$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true

The same issue, having the port changed to 2377, although the generated command after initializing the swarm manager indicates part 2376.

Gwen wants to work on this.

@nishanttotla can you help us understand the mismatch with the ports?

It worked with me following the solution listed in this post which suggested to advertise your address without specifying the port

$ docker-machine ssh myvm1 "docker swarm init --advertise-addr 192.168.99.100"

The link posted by @AnwarYagoub seems reasonable to me. That is the expected behavior.

Someone can tell me how to get this crap working?

HI @gggh000
I faced the same issue and just used an IP from docker-machine ls without a port part meaning that it will use default (2377) port.

Nope - just leaving away the port does not help!
I did so and got the very same error:

C:\windows\system32>docker-machine ls
NAME    ACTIVE   DRIVER   STATE     URL                        SWARM   DOCKER     ERRORS
myvm1   -        hyperv   Running   tcp://192.168.1.102:2376           v18.09.2
myvm2   -        hyperv   Running   tcp://192.168.1.113:2376           v18.09.2

C:\windows\system32>docker-machine ssh myvm1 "docker swarm init --advertise-addr 192.168.1.102"
Swarm initialized: current node (19gmiq7vr8smcdejw0p2rr0np) is now a manager.

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

    docker swarm join --token SWMTKN-1-58ibmapquculh9rd6zloubaik8avcbd4v5z8ns5906lxu7pn8b-50x2vb5oa58ti259gmvgjg4jy 192.168.1.102:2377

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

C:\windows\system32>docker-machine ssh myvm2 "docker swarm join --token SWMTKN-1-58ibmapquculh9rd6zloubaik8avcbd4v5z8ns5906lxu7pn8b-50x2vb5oa58ti259gmvgjg4jy 192.168.1.113"
Error response from daemon: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 192.168.1.113:2377: connect: connection refused"
exit status 1

C:\windows\system32> 

Any clue anyone how to get this working?

My error! I had misunderstood that I should take the machine's IP address as last argument here, but to join the swarm one needs to specify the swarm-manager's IP, i.e. as provided in the output from the swarm init command!

I.e. the last command must be:
docker-machine ssh myvm2 "docker swarm join --token SWMTKN-1-58ibmapquculh9rd6zloubaik8avcbd4v5z8ns5906lxu7pn8b-50x2vb5oa58ti259gmvgjg4jy 192.168.1.102"
and not ... 113!

Working now!

The tutorial desperately needs updated with the correct procedure. The text at https://docs.docker.com/get-started/part4/ still maintains, as a default procedure, we should specify port 2376 when initializing a swarm manager... Despite the short quip about default management ports, the tutorial instructions can be confusing and frustrating to new users. I suggest the example command be this:
docker-machine ssh myvm1 "docker swarm init --advertise-addr <myvm1 ip:2377>"

Thus the note following about management ports will be intuitive.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thaJeztah picture thaJeztah  路  4Comments

GPPassos picture GPPassos  路  3Comments

Bharathkumarraju picture Bharathkumarraju  路  3Comments

DanJ210 picture DanJ210  路  3Comments

MicheleMannino picture MicheleMannino  路  4Comments