I have the current application.conf
...
datastax-java-driver {
basic.contact-points = ["192.168.23.1:9042"]
basic {
load-balancing-policy {
local-datacenter = datacenter1
}
}
advanced.metrics {
factory.class = MicrometerMetricsFactory
}
advanced.request.warn-if-set-keyspace = false
advanced.auth-provider {
class = PlainTextAuthProvider
username = cassandra
password = cassandra
}
profiles {
slow {
basic.request.timeout = 10 seconds
}
}
}
I also have a env var with the IP address DOCKER_IP. I tried
basic.contact-points = ["${DOCKER_IP}:9042"]
But it didn't work and instead defaulted to the local computer.
The answer offered by @Madhavan above is absolutely correct. For sake of completeness I wanted to expand on it just a bit.
The Java driver uses the Typesafe Config lib to perform it's configuration. That lib provides a couple different methods for overriding config values at runtime. Out of the box you can override any config value by providing a system property that exactly matches the config name. So to override the specified contact points you could use the following flag when invoking the JVM:
The ".1" suffix is added here because "contact-points" is an array of values; see the docs for more detail.
The second option is to enable environment variable overrides for config values and then provide the appropriate env var. To enable this feature you should provide the following system property:
You can then provide the value for any config variable via an environment variable. For example, to accomplish the same replacement specified above you might use the following env var:
You can find additional information about the "CONFIG_FORCE_" prefix and the rules around translating config property names into environment variables in the Typesafe Config docs referenced above.