我正试图在窗口码头上设置红宝石俱乐部。它只在redis-cli -h 127.0.0.1、-p 6383中很好地工作,它位于码头容器CLI中,所有节点都很好,集群没有问题。这是redis.config文件节点之一。
redis.config文件
port 6383
bind 0.0.0.0
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes问题是使用上述配置的,不可能用应用程序访问集群,因为应用程序无法访问(这个应用程序在redis单模式下工作得很好)
当我将“绑定”redis.conf文件“绑定”到我的计算机ip (为192.168.3.205 )时,我得到了这个错误在这里输入图像描述
我尝试了以下几点:
telnet 192.168.3.205 6383和127.0.0.1 6383
这是我的.yml文件
version: "3.8"
networks:
default:
name: amin-cluster
services:
redis0:
container_name: node-0
image: mnadeem/redis
network_mode: "host"
volumes:
- C:\Windows\System32\6379\redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
build:
context: .
dockerfile: Dockerfile
hostname: node-0
restart: always
redis1:
container_name: node-1
image: mnadeem/redis
network_mode: "host"
volumes:
- C:\Windows\System32\6380\redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
build:
context: .
dockerfile: Dockerfile
hostname: node-1
restart: always
redis2:
container_name: node-2
image: mnadeem/redis
network_mode: "host"
volumes:
- C:\Windows\System32\6381\redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
build:
context: .
dockerfile: Dockerfile
hostname: node-2
restart: always
redis3:
container_name: node-3
image: mnadeem/redis
network_mode: "host"
volumes:
- C:\Windows\System32\6382\redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
build:
context: .
dockerfile: Dockerfile
hostname: node-3
restart: always
redis4:
container_name: node-4
image: mnadeem/redis
network_mode: "host"
volumes:
- C:\Windows\System32\6383\redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
build:
context: .
dockerfile: Dockerfile
hostname: node-4
restart: always
redis5:
container_name: node-5
image: mnadeem/redis
network_mode: "host"
volumes:
- C:\Windows\System32\6384\redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
build:
context: .
dockerfile: Dockerfile
hostname: node-5
restart: always
发布于 2021-10-31 14:49:01
在您的docker compose yml中,您需要发布端口,并为您希望从主机访问的每个服务设置一个端口。
redis0:
ports:
- "6383:6383"
...
redis1:
ports:
- "12345:6383"语法是"hostport:containerport",因为您有6个redis实例,假设您希望每个可访问的主机端口都不同。
如果不需要从主机访问端口,显然可以省略端口。
有关如何发布端口的详细信息,请参阅docker compose yml docs https://docs.docker.com/compose/compose-file/compose-file-v3/#ports。
https://stackoverflow.com/questions/69787518
复制相似问题