0

I am trying to setup Redis sentinel on docker, but sentinel container is not starting. I have one Master and one Slave with one Sentinel.

I am using ec2 ubuntu instance (t2 micro), where i have installed docker.

This is docker-compose.yaml

version: '3.5'

services:
  redis-master:
    container_name: "redis-master"
    image: redis
    ports:
      - "6379:6379"
    command: "redis-server /usr/local/etc/redis/redis.conf"
    volumes:
      - "./data/master:/data/"
      - "./master.conf:/usr/local/etc/redis/redis.conf"
    sysctls:
       - net.core.somaxconn=512
  redis-slave:
    container_name: "redis-slave"
    image: redis
    ports:
      - "6380:6379"
    command: "redis-server /usr/local/etc/redis/slave.conf"
    volumes:
      - "./data/slave:/data/"
      - "./slave.conf:/usr/local/etc/redis/slave.conf"
    sysctls:
       - net.core.somaxconn=512
  redis-sentinel:
    container_name: "redis-sentinel"
    image: redis
    ports:
      - "26379:26379"
    command: "redis-server /usr/local/etc/redis/sentinel.conf --sentinel"
    volumes:
      - "./sentinel.conf:/usr/local/etc/redis/sentinel.conf"
    sysctls:
       - net.core.somaxconn=512
    depends_on:
      - redis-master
      - redis-slave

After starting i am getting the below error and sentinel container is getting killed

Sentinel config file /usr/local/etc/redis/sentinel.conf is not writable: Permission denied. Exiting...

Kuldeep
  • 599
  • 11
  • 28

2 Answers2

0

redis uses the redis user when it's up , so you can make

chown redis:redis /etc/redis/sentinel.conf

in your redis-sentinel dockerfile or if you want to stick with the compose-file only, you can try

command: bash -c "
    chown redis:redis /etc/redis/sentinel.conf
    && redis-server /usr/local/etc/redis/sentinel.conf --sentinel
  "
0

The error occur because Sentinel needs write permission to the folder where the configuration file lives. Sentinel needs this permission to create temporary files and to be able to update the configuration file.

duckoak
  • 40
  • 5