s7anley/redis-sentinel-docker

sentinel get master return local network ip:port

huangjingfang opened this issue · 1 comments

I started the cluster successfully and then I try to use this cluster, but when I connect to sentinel, and get master info from it, it returns an ip in 172.x.x.x network.

here is the code:

import redis

r = redis.Redis(host='10.227.10.225', port=16379, db=0) # master
s = redis.Redis(host='10.227.10.225', port=16380, db=0) # salve

from redis.sentinel import Sentinel
st = Sentinel([('10.227.10.225', '26379')], password=pwd)
m = st.master_for('mymaster')
m.keys() 

and it raise an exception redis.exceptions.ConnectionError: Error 60 connecting to 172.28.0.2:6379. Operation timed out.
apparently master_for get an addr of the local network. is there any way to bind the network with host ip(like create a network with host type) to avoid this problem.

it seem this is a very common problem, it's ok I'll try other way to fix it