9

I am new to cluster. I can not see the difference between these two options? I think the advertise addr is used by other nodes to communicate with each other and listen addr is used by hosts to join in cluster. So I think these two addr will always be the same. Am I right?

YON
  • 1,607
  • 3
  • 18
  • 33

2 Answers2

8

Leaving --listen-addr at it's default 0.0.0.0:2377 tells it to listen on all interfaces for requests. You can use this to limit Swarm to only listen on specific interfaces if you have something like a management network that's separate from a public network on your nodes.

The --advertise-addr is the address given out to other nodes in the Swarm for establishing connections and needs to be an address everyone can resolve and reach.

Note that early RC's of 1.12 didn't have --advertise-addr so you may find some instructions indicating --listen-addr should be used. I'd disregard those and use --advertise-addr only unless you have a specific use case.

BMitch
  • 231,797
  • 42
  • 475
  • 450
2

You are correct, also listen addr is the address which the daemon will be accepting connections, ie. 0.0.0.0:<port> means the daemon is reachable from all possible ip addr. While 192.168.1.1:<port> means the daemon will only accept connections on that specific interface.

huygn
  • 980
  • 1
  • 13
  • 22
  • 1
    If this is true, then why docker split this into two options? – YON Aug 06 '16 at 15:45
  • 1
    advertise addr is used for swarm nodes discovery over the network, thus cannot be `0.0.0.0`. While listen addr is the address which the swarm daemon will be accepting connections from nodes within the network. – huygn Aug 06 '16 at 15:48