我希望有以下配置:
- 在主机A上有1个主节点和2个哨兵。
- 在主机B上有1个从节点和1个哨兵。
因此,对于主节点,我创建了以下dockerfile:
FROM redis
COPY redis.conf /etc/redis/redis.conf
COPY sentinel.conf /etc/redis/sentinel.conf
CMD [ "redis-server", "/etc/redis/redis.conf" ]
CMD [ "redis-sentinel", "/etc/redis/sentinel.conf" ]
CMD [ "redis-sentinel", "/etc/redis/sentinel.conf" ]
一切看起来都很好,当我尝试运行docker容器时,它没有抛出任何错误并且看起来很正常。但是,当我尝试使用redis-cli连接到容器时,我遇到了以下错误。
错误: 无法连接到127.0.0.1:6379的Redis:拒绝连接 我不明白为什么它无法连接?如果有人能告诉我是否以正确的方式创建了dockerfile?
注意:尝试使用以下命令进行连接
docker exec -it rdbcontainer redis-cli