Created
March 19, 2025 08:38
-
-
Save limboinf/faeb8b0100a92089fa1eb97247cd8888 to your computer and use it in GitHub Desktop.
redis sentinel docker compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
redis-master: | |
image: bitnami/redis:latest | |
ports: | |
- "6379:6379" | |
environment: | |
- REDIS_REPLICATION_MODE=master | |
- ALLOW_EMPTY_PASSWORD=yes | |
- REDIS_MASTER_HOST=127.0.0.1 # 使用本地回环地址 | |
networks: | |
- redis-net | |
# 添加主机名 | |
hostname: redis-master | |
# 添加额外的主机配置 | |
extra_hosts: | |
- "host.docker.internal:host-gateway" | |
redis-replica: | |
image: bitnami/redis:latest | |
ports: | |
- "6380:6379" | |
depends_on: | |
- redis-master | |
environment: | |
- REDIS_REPLICATION_MODE=slave | |
- REDIS_MASTER_HOST=redis-master | |
- ALLOW_EMPTY_PASSWORD=yes | |
- REDIS_MASTER_HOST=127.0.0.1 # 使用本地回环地址 | |
networks: | |
- redis-net | |
redis-sentinel-1: | |
image: bitnami/redis-sentinel:latest | |
ports: | |
- "26379:26379" | |
depends_on: | |
- redis-master | |
- redis-replica | |
environment: | |
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=5000 | |
- REDIS_MASTER_HOST=redis-master | |
- REDIS_MASTER_PORT_NUMBER=6379 | |
- REDIS_MASTER_SET=mymaster | |
- REDIS_SENTINEL_QUORUM=2 | |
- ALLOW_EMPTY_PASSWORD=yes | |
networks: | |
- redis-net | |
redis-sentinel-2: | |
image: bitnami/redis-sentinel:latest | |
ports: | |
- "26380:26379" | |
depends_on: | |
- redis-master | |
- redis-replica | |
environment: | |
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=5000 | |
- REDIS_MASTER_HOST=redis-master | |
- REDIS_MASTER_PORT_NUMBER=6379 | |
- REDIS_MASTER_SET=mymaster | |
- REDIS_SENTINEL_QUORUM=2 | |
- ALLOW_EMPTY_PASSWORD=yes | |
networks: | |
- redis-net | |
redis-sentinel-3: | |
image: bitnami/redis-sentinel:latest | |
ports: | |
- "26381:26379" | |
depends_on: | |
- redis-master | |
- redis-replica | |
environment: | |
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=5000 | |
- REDIS_MASTER_HOST=redis-master | |
- REDIS_MASTER_PORT_NUMBER=6379 | |
- REDIS_MASTER_SET=mymaster | |
- REDIS_SENTINEL_QUORUM=2 | |
- ALLOW_EMPTY_PASSWORD=yes | |
networks: | |
- redis-net | |
networks: | |
redis-net: | |
driver: bridge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment