version: '3'
services:
  redis-1:
    image: redis:5.0.5
    container_name: redis-1
    ports:
      - 6380:6379
  redis-2:
    image: redis:5.0.5
    container_name: redis-2
    ports:
      - 6381:6379
    command:  redis-server --slaveof redis-1 6379
    # 让两个slave节点去复制container_name为redis-master的节点，这样就组成了一个简单的3个节点的主从架构
  redis-3:
    image: redis:5.0.5
    container_name: redis-3
    ports:
      - 6382:6379
    command: redis-server --slaveof redis-1 6379
    # 让两个slave节点去复制container_name为redis-master的节点，这样就组成了一个简单的3个节点的主从架构

  sentinel-1:
    image: redis:5.0.5
    container_name: redis-sentinel-1
    ports:
      - 26379:26379
    command: redis-sentinel /usr/local/etc/redis/sentinel.conf
    volumes:
      - ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf
  sentinel-2:
    image: redis:5.0.5
    container_name: redis-sentinel-2
    ports:
      - 26380:26379
    command: redis-sentinel /usr/local/etc/redis/sentinel.conf
    volumes:
      - ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf
  sentinel-3:
    image: redis:5.0.5
    container_name: redis-sentinel-3
    ports:
      - 26381:26379
    command: redis-sentinel /usr/local/etc/redis/sentinel.conf
    volumes:
      - ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf