I'm trying to connect a my .net core 6 app to a configuration of 3 nods (1 master + 2 slaves) + 3 sentinels.

Attaching the following

master config

protected-mode no 
bind 0.0.0.0 
port 6379 

masterauth pass 
requirepass pass

slave config

protected-mode no
bind 0.0.0.0
port 6379
replicaof 172.128.3.10 6379

masterauth pass
requirepass pass

sentinel1

port 6379
protected-mode no

sentinel announce-ip 172.128.3.13

sentinel myid 5bdaf984e15ec43bfde835d04d485848acbab78c
sentinel known-sentinel redismaster 172.128.3.14 6379 d8de0f4bcb59725cea695791379094ea12bfbde5
sentinel known-sentinel redismaster 172.128.3.15 6379 326f98bb6afca0ff9db88513ebcc0050033706f4

sentinel deny-scripts-reconfig yes
sentinel monitor redismaster 172.128.3.10 6379 2
sentinel auth-pass redismaster pass
sentinel down-after-milliseconds redismaster 5000
sentinel failover-timeout redismaster 60000

dir "/data"

sentinel known-replica redismaster 172.128.3.11 6379
sentinel known-replica redismaster 172.128.3.12 6379

sentinel resolve-hostnames no
sentinel announce-hostnames no

sentinel2

port 6379
protected-mode no

sentinel announce-ip 172.128.3.14

sentinel myid 5bdaf984e15ec43bfde835d04d485848acbab78c
sentinel known-sentinel redismaster 172.128.3.13 6379 d8de0f4bcb59725cea695791379094ea12bfbde5
sentinel known-sentinel redismaster 172.128.3.15 6379 326f98bb6afca0ff9db88513ebcc0050033706f4

sentinel deny-scripts-reconfig yes
sentinel monitor redismaster 172.128.3.10 6379 2
sentinel auth-pass redismaster pass
sentinel down-after-milliseconds redismaster 5000
sentinel failover-timeout redismaster 60000

dir "/data"

sentinel known-replica redismaster 172.128.3.11 6379
sentinel known-replica redismaster 172.128.3.12 6379

sentinel resolve-hostnames no
sentinel announce-hostnames no

sentinel3

port 6379
protected-mode no

sentinel announce-ip 172.128.3.15

sentinel myid 5bdaf984e15ec43bfde835d04d485848acbab78c
sentinel known-sentinel redismaster 172.128.3.13 6379 d8de0f4bcb59725cea695791379094ea12bfbde5
sentinel known-sentinel redismaster 172.128.3.14 6379 326f98bb6afca0ff9db88513ebcc0050033706f4

sentinel deny-scripts-reconfig yes
sentinel monitor redismaster 172.128.3.10 6379 2
sentinel auth-pass redismaster pass
sentinel down-after-milliseconds redismaster 5000
sentinel failover-timeout redismaster 60000

dir "/data"

sentinel known-replica redismaster 172.128.3.11 6379
sentinel known-replica redismaster 172.128.3.12 6379

sentinel resolve-hostnames no
sentinel announce-hostnames no

dockerfile for slaves, master, sentinels is the same, I'm building on top of redis 7 copy and copy the .conf files and replace.

FROM redis:7.0-alpine
COPY redis.conf /config/redis.conf
redis-node-1:
    build:
      context: ./governance.infraLayer/redis-ha/redis-0
      dockerfile: ./master.dockerfile
    image: redis:master
    container_name: redis-node-1
    networks:
      governance-local:
        ipv4_address: 172.128.3.10
    ports:
      - 6370:6379
    volumes:
      - /redis-node-1-volume:/data
    restart: unless-stopped
    command: "redis-server /config/redis.conf"

  redis-node-2:
    build:
      context: ./governance.infraLayer/redis-ha/redis-1
      dockerfile: ./slave.dockerfile
    image: redis:slave
    container_name: redis-node-2
    networks:
      governance-local:
        ipv4_address: 172.128.3.11
    ports:
      - 6371:6379
    depends_on:
      - redis-node-1
    volumes:
      - /redis-slave1-volume:/data
    restart: unless-stopped
    command: "redis-server /config/redis.conf"

  redis-node-3:
    build:
      context: ./governance.infraLayer/redis-ha/redis-2
      dockerfile: ./slave.dockerfile
    image: redis:slave
    container_name: redis-node-3
    networks:
      governance-local:
        ipv4_address: 172.128.3.12
    ports:
      - 6372:6379
    depends_on:
      - redis-node-1
    volumes:
      - /redis-slave2-volume:/data
    restart: unless-stopped
    command: "redis-server /config/redis.conf"

  redis-sentinel-1:
    build:
      context: ./governance.infraLayer/redis-ha/sentinel-0
      dockerfile: ./sentinel.dockerfile
    image: redis:sentinel
    container_name: redis-sentinel-1
    networks:
      governance-local:
        ipv4_address: 172.128.3.13
    ports:
      - 6380:6379
    depends_on:
      - redis-node-1
      - redis-node-2
      - redis-node-3
    volumes:
      - /redis-sentinel1-volume:/data
    restart: unless-stopped
    command: "redis-sentinel /config/redis.conf"

  redis-sentinel-2:
    build:
      context: ./governance.infraLayer/redis-ha/sentinel-1
      dockerfile: ./sentinel.dockerfile
    image: redis:sentinel
    container_name: redis-sentinel-2
    networks:
      governance-local:
        ipv4_address: 172.128.3.14
    ports:
      - 6381:6379
    depends_on:
      - redis-node-1
      - redis-node-2
      - redis-node-3
    volumes:
      - /redis-sentinel2-volume:/data
    restart: unless-stopped
    command: "redis-sentinel /config/redis.conf"

  redis-sentinel-3:
    build:
      context: ./governance.infraLayer/redis-ha/sentinel-2
      dockerfile: ./sentinel.dockerfile
    image: redis:sentinel
    container_name: redis-sentinel-3
    networks:
      governance-local:
        ipv4_address: 172.128.3.15
    ports:
      - 6382:6379
    depends_on:
      - redis-node-1
      - redis-node-2
      - redis-node-3
    volumes:
      - /redis-sentinel3-volume:/data
    restart: unless-stopped
    command: "redis-sentinel /config/redis.conf"

I'm running Windows10 22H2 (19045.2251) Docker Desktop 4.13.1 (90346) with wsl2 integration (my wsl distro is Ubuntu-22.04).

My infrastructure runs inside docker containers. I'm not running my .net 6 app inside docker container (so it is not deployed as a container yet) but from my host in debug mode (using visual studio 2022 professionl)

I'm ssh-ing into any of the nodes that are running inside docker container and I can execute actions for example for master I can create a key with a value, the key is then replicated to other nodes (the slaves). I stop the master container and I can see that the sentinels choose another master, and the other slave syncs with the new master. I bring back the old master and I can see that it is a slave. I can ssh into antoher redis node inside the cluster from within session inside the initial container. Example, I'm sshing into node-1 and following are the steps

docker exec -it sh redis-cli -h 172.128.3.11 -p 6379 -a pass

And a new session with the node at the address 172.128.3.11 is created.

So everything seems to work but in some kind of isolation, this is because I cannot reach from outside to this cluster.

In my .net core 6 app I'm using stackesxchange.redis library and I configured my connection as it should attaching the conversion with collaborator of stackexchange.redis library (https://github.com/StackExchange/StackExchange.Redis/issues/2297). I've tried to see if I can reach the cluster from outside. I've installed redis inside my default wsl distro (ubuntu 22.04).

I have the following vesrion

> redis-cli 6.0.16

And I'm trying to reach a node inside the cluster. in this case it is the master node as per docker-compose config

redis-cli -h localhost -p 6370 -a pass

Redis Connect to a redis sentinel configuration running in docker from host

And I can see that I can connect as can be seen from the snapshot. I can reach both a sentinel and a node.

However, I cannot do that from my net core app , I mean [providing the same host "localhost" the same port the connection fails.

So to summarize,

I'm running a sentinel setup inside docker and I'm trying to connect my .net core 6 app running on win 10 host.

Comment From: moticless

Hi @remus-corneliu, without going into details. Looks like you have issue with access container from the host. You do manage to reach instances from inside containers network. If that so, then this issue is behind the scope of this repo.