docker/redis/docker-compose-ha.yml

95 lines
2.5 KiB
YAML
Raw Normal View History

2017-07-17 10:35:32 +08:00
version: '3'
networks:
&network network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/16
services:
&master redis-master:
image: &image registry.cn-hangzhou.aliyuncs.com/kennylee/redis:3.2
2017-07-17 10:35:32 +08:00
container_name: "master"
ports:
- "6379:6379"
restart: on-failure
command: [ "redis-server" ]
2017-07-17 10:35:32 +08:00
networks:
*network :
ipv4_address: 172.16.238.10
redis-slave-1:
image: *image
2017-07-17 10:35:32 +08:00
container_name: "slave"
ports:
- "6380:6379"
restart: on-failure
command: [ "redis-server","--slaveof","172.16.238.10", "6379","--slave-read-only","yes"]
2017-07-17 10:35:32 +08:00
networks:
*network :
ipv4_address: 172.16.238.11
depends_on:
- *master
2017-09-16 01:23:00 +08:00
redis-sentinel-1:
build:
context: ./conf-ha/
dockerfile: Dockerfile-sentinel
container_name: "s1"
2017-07-17 10:35:32 +08:00
ports:
- "26379:26379"
restart: on-failure
command: [ "redis-sentinel", "/usr/local/etc/redis/sentinel.conf" ]
networks:
*network :
2017-09-16 01:23:00 +08:00
ipv4_address: 172.16.238.21
2017-07-17 10:35:32 +08:00
depends_on:
- *master
2017-09-16 01:23:00 +08:00
redis-sentinel-2:
build:
context: ./conf-ha/
dockerfile: Dockerfile-sentinel
container_name: "s2"
ports:
- "26380:26379"
restart: on-failure
command: [ "redis-sentinel", "/usr/local/etc/redis/sentinel.conf" ]
networks:
*network :
ipv4_address: 172.16.238.22
depends_on:
- *master
redis-sentinel-3:
build:
context: ./conf-ha/
dockerfile: Dockerfile-sentinel
container_name: "s3"
ports:
- "26381:26379"
restart: on-failure
command: [ "redis-sentinel", "/usr/local/etc/redis/sentinel.conf" ]
networks:
*network :
ipv4_address: 172.16.238.23
depends_on:
- *master
redis-sentinel-4:
build:
context: ./conf-ha/
dockerfile: Dockerfile-sentinel
container_name: "s4"
ports:
- "26382:26379"
restart: on-failure
command: [ "redis-sentinel", "/usr/local/etc/redis/sentinel.conf" ]
networks:
*network :
ipv4_address: 172.16.238.24
depends_on:
- *master
2017-07-17 10:35:32 +08:00