Docker Community Forums

Share and learn in the Docker community.

Docker swarm init --listen-addr=0.0.0.0:2377 has no effect on port 2377


(Freiit) #1

Expected behavior

Expect my newly reconfigured docker host to become the swarm leader AND exposes port 2377 to the outside world.

Actual behavior

swarm started and all services work as expected, but: port 2377 is not reachable from the outside world. (Not even from the inside world: ‘lsof -i -P -n | grep LISTEN’ doesn’t show any open port 2377 on any ethernet card.)

Am I doing something wrong? Would like to connect a second host…


(Llitfkitfk) #2

same issue!:hamburger:


(Finid) #3

The listen-address you specified is the default, so you don’t have to specify it when you initialize the swarm. I have a 2-node cluster running on Ubuntu 16.04 that’s running 5 services.

Even though lsof does not show the server listening on port 2377, I can join a node to the cluster using

docker swarm join --secret <secret-here> ip-address-of-manager:2377

The Swarm was initialized using:

docker swarm init --secret <secret-here>

Give it another try.


(Freiit) #4

Thanks, I’m sure it’s not a general problem. But that’s the docker4mac section and it seems not to work here.
If I want to set up a single host swarm - how can I disable the listening? Binding to 127.0.0.1?


(Finid) #5

A single-node Swarm is not really a cluster, but you can try --listen-addr=127.0.0.1:2377 and see if it works.

Note that I’ve not tried that myself, so you’re the test-case.


(Freiit) #6

No, doesn’t work. Tried to find access to that little VM (xhyve clone), but have no idea how. So I could at least check if the port is open locally within that VM…


(Finid) #7

Perhaps that’s by design, because a Swarm manager listening on the loopback address will not be able to manage a cluster.


(Llitfkitfk) #8

u can try using docker in docker ‘docker:1.12.0-rc2-dind’ to build docker for mac swarm cluster or expose the ports in dind for multiple local macs swarm cluster.
:tea:


(Bret Fisher) #9

So this may be due to the difference between the typical swarm mode that you would create on linux machines vs. the simulated methods that Docker for Mac goes though to make you think it’s really running on your localhost Mac when it’s actually running on the xhyve linux VM. I don’t have the specific steps in front of me but if you want your DfM docker instance to be in a multi-server swarm mode you’ll need to google for extra steps/hacks, as it’s kinda beyond expected behavior for DfM/DfW.

If I was wanting to build a multi-server swarm mode locally I’d still use docker-machine with virtualbox.