Docker Redis gives error when booting with -v to persistent storage (chown: changing ownership of ‘.’ : Permission denied)
I’m using the default settings for docker-redis with the following system versions/specs redis.conf .
Redhat version: 7.6 (Red Hat Enterprise Linux Server)
Redis Version: 5.0.4
Docker Version: 1.13.1, build b2f74b2/1.13.1
When I run the following command, it works just fine.
sudo docker run -d -v $PWD/redis.conf:/usr/local/etc/redis/redis.conf --name redis-persistance --net tyk -p 7070:6379 redis redis-server /usr/local/etc/redis/redis.conf -- appendonly yes
I need to fetch the redis data (/data
inside the container) to the host directory (/usr/local/etc/redis/data) < strong>(-v $PWD/data:/data). So when I run the following command, I get the following error.
Note $PWD =/usr/local/etc/redis/
sudo docker run -d -v $PWD/redis.conf:/usr/local/etc/redis/redis.conf -v $PWD/data:/data --name redis-persistance --net tyk -p 7070:6379 redis redis-server /usr/local/etc/ redis/redis.conf --appendonly yes
Error in docker logs:
journal: chown: changing ownership of '.': Permission denied
level=warning msg="05ce842f052e28566aed0e2eab32281138462cead771033790266ae145fce116 cleanup: failed to unmount secrets: invalid argument"
I also tried changing the ownership of the data folder in the host to following as well. Chown Redis: Redis data
drwxrwxrwx. 2 redis redis 6 May 3 07:11 data
Can anyone help me with this. Thank you.
Solution
First create a volume:
docker volume create redis_data
Check that the volume has been created (note the mount point):
docker volume inspect redis_data
Then use this volume to start your container:
sudo docker run -d -v $PWD/redis.conf:/usr/local/etc/redis/redis.conf -v redis_data:/data --name redis-persistance --net tyk -p 7070:6379 redis redis-server /usr/local/etc/ redis/redis.conf --appendonly yes
You can then look at the contents of “Mountpoint”, which should be redis data.