Docker Community Forums

Share and learn in the Docker community.

Redis:Failed opening .rdb for saving: Permission denied

  • CentOS7.5
  • I pulled redis:5.0 from dockerhub.
  • Started docker with command below:

docker run --name redis5 -v /data/db:/data -p 6379:6379 -d redis:5.0

This docker running quite well for several days. However today it suddenly report errors below:

19263:C 22 Nov 2019 02:04:49.035 # Failed opening the RDB file web (in server root dir /etc) for saving: Permission denied
1:M 22 Nov 2019 02:04:49.135 # Background saving error
1:M 22 Nov 2019 02:04:55.051 * 1 changes in 900 seconds. Saving…
1:M 22 Nov 2019 02:04:55.052 * Background saving started by pid 19264
19264:C 22 Nov 2019 02:04:55.052 # Failed opening the RDB file web (in server root dir /etc) for saving: Permission denied
1:M 22 Nov 2019 02:04:55.152 # Background saving error
1:M 22 Nov 2019 02:05:01.072 * 1 changes in 900 seconds. Saving…
1:M 22 Nov 2019 02:05:01.073 * Background saving started by pid 19265
19265:C 22 Nov 2019 02:05:01.073 # Failed opening the RDB file web (in server root dir /etc) for saving: Permission denied

My root db file is in “/data” in the container, why it try to access “/etc”? How can I fix this problem?

Thanks

i‘ve got this problem because previously redis don’t stopped completely and exists Residual Process .
you could found the port of redis already binded (in use ) at log file redis.log.
just run :
kill -9 redis-pid
restart redis service

share url : https://bit.ly/3hOnLaN

You should check your redis.conf file to see the permissions in dir and dbfilename. If the file named in the dbfilename which is located in the path specified in the dir path exists and the permission is also right. then the problem should be fixed.

Hope this will help someone.

P.S.

To find the redis.conf file location, you can use the #ps ax | grep redis to check. Usually it will be passed to the redis-server as input file.

For the dir permissions:it should be 755, for the dbfilename, it should be 644

Sometimes you also need to use top command to check whether the user:group of the redis-server and the owner of dir are consistent. i.e. The redis-server is running by redis:redis, but the dir is under root:root. In this case, you need to chown redis:redis -R dir.