0

Hi I have following docker-compose.yaml file.

version: "3.9"

volumes:
  local_postgres_data2: {}
  local_postgres_data_backups2: {}

services:
  postgres:
    image: postgres
    container_name: angel-postgres
    restart: always
    volumes:
      - local_postgres_data2:/var/lib/postgresql/data:Z
      - local_postgres_data_backups2:/backups:z
    environment:
      POSTGRES_DB: angel-agility
      POSTGRES_HOST: localhost
      POSTGRES_USER: angel-user
      POSTGRES_PASSWORD: angel123
    ports:
      - "5432:5432"

  redis:
    container_name: angel-redis
    image: redis:latest
    ports:
      - '6379:6379'
    restart: unless-stopped

When I run docker-compose up I get error in logs for Redis:

2276:C 29 Mar 2022 20:32:52.005 # Failed opening the RDB file crontab (in server root dir /etc) for saving: Permission denied
1:M 29 Mar 2022 20:32:52.105 # Background saving error

I tried all the solutions on different platforms but couldn't make Redis work. A clue or direction make it work will be highly appreciated.

Also a little brief about the problem in detail why its happening would also be great help for readers and me. Looking forward.

1 Answers1

0

I've encountered the same issue running a redis container on AWS ECS in a similar fashion.

I connected to the redis container and executed:

redis-cli
> CONFIG GET dbfilename

It returned the following:

1) "dbfilename"
2) "crontab"

I tried to remove the crontab file by running config set dbfilename "dbfilename" which failed with an error.

I've found out that redis was running without a config file. So I added an extra volume for redis and created the file using touch data/redis/config/redis.conf.

Then I've changed my compose file accordingly:

  redis:
    container_name: redis
    command: redis-server /conf/redis.conf
    image: redis:latest
    volumes:
       - "./data/redis/data:/data"
       - "./data/redis/config:/conf"
    ports:
      - '6379:6379'
    restart: unless-stopped

After rebooting the container I've run the same CONFIG GET dbfilename command but this time the crontab file was missing.

Everything worked after that :)

Redis Config

Also make sure that you set a password for your redis server if it's accessible from the internet.

    docker run -d \
    -h redis \
    -e REDIS_PASSWORD=your-super-secure-password \
    -v redis-data:/data \
    -v redis-config:/conf \
    -p 6379:6379 \
    --name redis \
    --restart always \
    redis:latest /bin/sh -c 'redis-server /conf/redis.conf --appendonly yes --requirepass ${REDIS_PASSWORD}'
posixpascal
  • 176
  • 5