0

I'm running this docker-compose.yaml on my machine (Mac with docker desktop) but am not able to connect the cluster with redis-cli.

I'm running it with

docker-compose up --build

I'm able to run redis-cli from within the containers like

❯ docker exec -it docker-redis-cluster_redis-1_1 redis-cli -c -p 7001                                                                                       (eks-dev-blue/itamar)
127.0.0.1:7001> cluster nodes
c9c01ea75f43780f36f3dca445410c1c902bda0b 10.0.0.16:7006@17006 slave cc69a5c2467fff36daa62acefc70b4b49d7a22a6 0 1643633817569 2 connected
cc69a5c2467fff36daa62acefc70b4b49d7a22a6 10.0.0.12:7002@17002 master - 0 1643633816000 2 connected 5461-10922
9c1d48c16402c651578b4722ceb699aa0effa392 10.0.0.11:7001@17001 myself,master - 0 1643633816000 1 connected 0-5460
c83836c357ce77cf845cda983aa76aa7942e2489 10.0.0.14:7004@17004 slave 5bdf05a8d332646ee76ff0da64fb97570cf7117e 0 1643633816558 3 connected
5bdf05a8d332646ee76ff0da64fb97570cf7117e 10.0.0.13:7003@17003 master - 0 1643633817974 3 connected 10923-16383
115b037e3dc2de23389a3b085b4242b63bfa887a 10.0.0.15:7005@17005 slave 9c1d48c16402c651578b4722ceb699aa0effa392 0 1643633817000 1 connected

But I'm not able to communicate with the cluster from my host machine:

❯ redis-cli -c -h localhost -p 7001                                                                                                                                       (eks-prod-blue/prod)
127.0.0.1:7001> cluster nodes
Error: Server closed the connection

What am I missing? Is it a missing network\ports config?

1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Jan 31, 2022 at 8:02

1 Answer 1

0

You're creating the following network and your services get IPs from this range.

  redisnet:
    driver: bridge
    ipam:
      config:
        - subnet: 10.0.0.0/16

Which container are you connecting to? Does the IP get resolved correctly? Does your host machine know how to reach the 10.0.0.0/16 subnet? You need to have a entry in your route table that sends the traffic for 10.0.0.0/16 through the bridge adapter created for the redisnet network.

2
  • I guess I don't know how to config my host machine to use this subnet
    – itamar
    Jan 31, 2022 at 14:37
  • Use the route -n command to see all your routes. Check if one exists for 10.0.0.0/16 and which device is displayed as the gateway. If you don't see any, then you need to list all your interfaces with ifconfig -a and find the one that is of type bridge and has an address in the 10.0.0.0/16 subnet. Use the ip route add 10.0.0.0/16 dev <device-you-found> command to add the route.
    – theUndying
    Jan 31, 2022 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.