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?
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.