I have the following setup with Docker-Compose:
version: '2'
services:
redis-sentinel:
image: docker.io/bitnami/redis-sentinel:6.2
volumes:
- redis-sentinel_data:/bitnami
redis:
image: docker.io/bitnami/redis:6.2
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- redis_data:/bitnami
volumes:
redis-sentinel_data:
driver: local
redis_data:
driver: local
The name is my master should be mymaster
:
(base)>docker exec redis_redis-sentinel_1 redis-cli -p 26379 sentinel get-master-addr-by-name mymaster
192.168.80.3
6379
I try to connect via Python:
from redis.sentinel import Sentinel
sentinel = Sentinel([("localhost", 26379)], socket_timeout=0.5)
r = sentinel.master_for("mymaster")
This results in the following error.
redis.sentinel.MasterNotFoundError: No master found for 'mymaster'
What I tried:
- change localhost to my docker host IP adresss
- checking of
get-master-addr-by-name
with other names works => it does not - Increased socket_timeout to 5 seconds (https://github.com/redis/redis-py/issues/1125)
So what am I doing wrong here?