'Failed opening the RDB file root (in server root dir /etc/crontabs) for saving: Permission denied

I got this error when deploy docker-compose with redis

220:C 23 Jul 2020 11:21:59.091 # Failed opening the RDB file root (in server root dir /etc/crontabs) for saving: Permission denied

1:M 23 Jul 2020 11:21:59.191 # Background saving error

My docker-compose file is

version: '3'
services:
 main-otp-api:
  image: "mainotp/api:latest"
  ports:
   - "5000:5000"
 redis:
  image: "redis:alpine"
  ports:
   - "6379:6379"
  volumes: 
   - /home/mainotp-server/redis:/data
   - /home/mainotp-server/conf/redis.conf:/usr/local/etc/redis/redis.conf

Anyone can help me?



Solution 1:[1]

So for anyone experiencing this problem, here is a fix that will sort you out. Access the redis container shell with an interactive terminal

docker exec -it redis-container-id /bin/bash

Output will look something like this root@c4da3f40b65f:/data#.
Run cd to go the root of the file directory. Output root@c4da3f40b65f:~#.

At the root change the file permissions for /data and /etc

Run

chmod 777 -R /data  // for the data directory
chmod 777 -R /etc   // for etc folder.

You do not have to worry about the user group issues.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrew Mititi