version: "3"
# 定义服务可以多个
services:
redis-cluster:
image: redis:latest
command: redis-cli --cluster create 192.168.2.79:7901 192.168.2.79:7902 192.168.2.79:7903 192.168.2.79:7904 192.168.2.79:7905 192.168.2.79:7906 --cluster-replicas 1 --cluster-yes -a 123456
depends_on:
- redis-7901
- redis-7902
- redis-7903
- redis-7904
- redis-7905
- redis-7906
redis-7901: # 服务名称
image: redis:latest # 创建容器时所需的镜像
container_name: redis-7901 # 容器名称
restart: always # 容器总是重新启动
ports:
- 7901:7901
- 17901:17901
volumes: # 数据卷,目录挂载
- ./etc_rc.local:/etc/rc.local
- ./7901/redis.conf:/etc/redis/redis.conf
- ./7901/data:/data
command: ["redis-server", "/etc/redis/redis.conf"] # 覆盖容器启动后默认执行的命令
redis-7902: # 服务名称
image: redis:latest # 创建容器时所需的镜像
container_name: redis-7902 # 容器名称
restart: always # 容器总是重新启动
ports:
- 7902:7902
- 17902:17902
volumes: # 数据卷,目录挂载
- ./etc_rc.local:/etc/rc.local
- ./7902/redis.conf:/etc/redis/redis.conf
- ./7902/data:/data
command: ["redis-server", "/etc/redis/redis.conf"] # 覆盖容器启动后默认执行的命令
redis-7903: # 服务名称
image: redis:latest # 创建容器时所需的镜像
container_name: redis-7903 # 容器名称
restart: always # 容器总是重新启动
ports:
- 7903:7903
- 17903:17903
volumes: # 数据卷,目录挂载
- ./etc_rc.local:/etc/rc.local
- ./7903/redis.conf:/etc/redis/redis.conf
- ./7903/data:/data
command: ["redis-server", "/etc/redis/redis.conf"] # 覆盖容器启动后默认执行的命令
redis-7904: # 服务名称
image: redis:latest # 创建容器时所需的镜像
container_name: redis-7904 # 容器名称
restart: always # 容器总是重新启动
ports:
- 7904:7904
- 17904:17904
volumes: # 数据卷,目录挂载
- ./etc_rc.local:/etc/rc.local
- ./7904/redis.conf:/etc/redis/redis.conf
- ./7904/data:/data
command: ["redis-server", "/etc/redis/redis.conf"] # 覆盖容器启动后默认执行的命令
redis-7905: # 服务名称
image: redis:latest # 创建容器时所需的镜像
container_name: redis-7905 # 容器名称
restart: always # 容器总是重新启动
ports:
- 7905:7905
- 17905:17905
volumes: # 数据卷,目录挂载
- ./etc_rc.local:/etc/rc.local
- ./7905/redis.conf:/etc/redis/redis.conf
- ./7905/data:/data
command: ["redis-server", "/etc/redis/redis.conf"] # 覆盖容器启动后默认执行的命令
redis-7906: # 服务名称
image: redis:latest # 创建容器时所需的镜像
container_name: redis-7906 # 容器名称
restart: always # 容器总是重新启动
ports:
- 7906:7906
- 17906:17906
volumes: # 数据卷,目录挂载
- ./etc_rc.local:/etc/rc.local
- ./7906/redis.conf:/etc/redis/redis.conf
- ./7906/data:/data
command: ["redis-server", "/etc/redis/redis.conf"] # 覆盖容器启动后默认执行的命令