Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker swam mode - What's the difference between --advertise-addr and --listen-addr?

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?

like image 790
YON Avatar asked Aug 06 '16 15:08

YON


2 Answers

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.

like image 180
BMitch Avatar answered Oct 11 '22 01:10

BMitch


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.

like image 34
huygn Avatar answered Oct 10 '22 23:10

huygn