How does docker-compose example know where the other nodes are? (it uses `localhost`)

Following the example found at scylla-code-samples/mms at master · scylladb/scylla-code-samples · GitHub I see that the configuration used within the first cluster has:

# Address or interface to bind to and tell other Scylla nodes to connect to.
# You _must_ change this if you want multiple nodes to be able to communicate!
#
# Setting listen_address to 0.0.0.0 is always wrong.
listen_address: localhost

# Address to broadcast to other Scylla nodes
# Leaving this blank will set it to the same value as listen_address
# broadcast_address: 1.2.3.4

Yet running nodetool status I see the cluster:

Datacenter: DC1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens       Owns    Host ID                               Rack
UN  172.24.0.2  920 KB     256          ?       b71f2176-e8eb-4dd1-9c0a-dd06ccfe6c54  Rack1
UN  172.24.0.3  544 KB     256          ?       1781ddb4-2e36-48f2-b918-87dda29b8738  Rack1
UN  172.24.0.4  880 KB     256          ?       d2b4d33b-8a02-429b-a7e3-83e7681b86b4  Rack1

Given that they are advertising localhost, I would assume they would not be able to connect to each other. I do see the seeds, but my assumption is that they wouldn’t be able to talk to each other like this for operations such as repairs and relaying queries.

How does localhost allow them to both listen and discover?

Is this just some docker networking magic?

In the docker-compose of the MMS example, the nodes use a bridge network to allow the containers to communicate.
The seed nodes are defined with an IP address, which allows them to discover each other.
You can read more about running ScyllaDB on Docker here.

I guess I’m wondering why it’s not trying to use local host despite it advertising that as default, but instead overrides and uses the docker ip.

Generally, using the command line flags overwrites scylla.yaml settings.
In this case, the seed nodes are provided when starting Docker, and that’s how they find each other.
The listen_address setting for the node sets the address or interface to bind to and tells other Scylla nodes how to connect to the node.

The listen_address is still local host though, it’s not being overridden by a flag. My questions is more how that works but it’s not a burning one. Asking others apparently Docker can resolve that to the containers ip within the network, but not sure if that’s true

@danthegoodman1
it’s localhost since it’s using docker, each scylla is listen to it’s own localhost
each docker instance has it’s own virtual network device
when you configure each one to connect with the others it would be using the actually address, i.e. what set in the broadcast_address