Redis cluster requires that all nodes can see each other to chatter; to accommodate some trivial situations (eg. docker with all nodes publicly exposed) some additional config options are available:
cluster-announce-ip 10.1.1.5
cluster-announce-port 6379
cluster-announce-bus-port 6380
(see http://download.redis.io/redis-stable/redis.conf for the only available documentation on these options)
Notice these values are hard coded into the config file. This is extremely inconvenient.
Is it possible to somehow configure redis to use a hostname instead of an IP for the endpoint? Is there any workaround for this?
As a tangible example of why this is required, consider attempting to configure a test redis cluster in a docker image with multiple redis instances on the single container via a Dockerfile:
If
cluster-announce-ip
is set, all nodes attempt to chatter viacluster-announce-ip
.If
cluster-announce-ip
is an external IP, since the docker image is not being run with-p
duringdocker build...
, the external IP is not available and the cluster cannot be configured.If
cluster-announce-ip
is not set, the cluster can be configured, but since the ip is docker-internal, it cannot be seen externally once the cluster is running (external clients will complain when they get aMOVED 10.0.0.x:2321
which is not visible to the external client).You must use
docker build ...
and then manually provision the nodes usingdocker commit ...
to snapshot the result.\When you run the container on a different physical host, you have to update the image manually to change the announce ip (When using DHCP this become even more problematic).
I appreciate docker swarm is one possible solution to this issue in general, but for testing purposes (eg. local development) it's not a relevant solution.
Simply using hostnames instead of ips would allow developers to just use host file entries to connect instead of having to manually update the docker image for every developer (obviously each development machine has its own external ip).