Fabien
Fabien

Reputation: 41

Create redis cluster (v5) with docker compose

It's been several days now trying to create a redis cluster with docker-compose, but it doesn't work because redis doesn't send a good ip address when my client sends a request (it sends to my host internal ip from docker, but i want he send host ip).

I'm looking for "cluster-announce-ip" but no success.

I've tried to create with host mode but it doesn't work ... I don't understand why..

Now redis-cli shows:

Waiting for the cluster to join

You could find my work here: https://github.com/fhebuterne/redis-cluster

If someone has a solution, I'm interested

Thanks

Upvotes: 1

Views: 3513

Answers (1)

Fabien
Fabien

Reputation: 41

After some tests, it not possible to use internal network in docker with multiple docker container and redis cluster (even with "cluster-announce-ip"), so the only solution i has found, is to define on each service (on docker compose), this option :

network_mode: "host"

And using the brige docker ip between host and containers, on windows i found it with ipconfig and look for "vEthernet (DockerNAT)", base ip is 10.0.75.1, on my redis-cli and redis.conf, i put 10.0.75.2, so each containers can be connected with others and cluster send good response when i send request with my host computer, i'm sorry if is not clear, i has push my solution on my repository (the link is on my previous message).

Upvotes: 2

Related Questions