redis: Permissions on mounted /data volume not correct
I’m running this instance with the /data directory mounted to the host machine with
-v /data/redis:/data
For some reason the permissions on the volume are not getting set properly despite the chown call in the Dockerfile, and therefore Redis pukes when trying to persist the DB.
Any ideas?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 20 (7 by maintainers)
I’ve found when host mounting data volumes, you often have to pre-create them and set the permissions to 999:999. In some cases host mounting is very hard, such as with Postgres. I’ve stopped doing host-mounting entirely and have embraced volume containers, which make these problems go away.
when i pre-create the directory
./mongo-datawith ownership ofubuntu:ubuntuand then I rundocker-compose up --buildit changes the owner to999and then docker gives a permission denied error.Does it work if you manually
chown -R 999:999 /data/redison your host?(If you’re wondering where the “999” came from, see
docker run -it --rm redis id, which providesuid=999(redis) gid=999(redis) groups=999(redis).)When you bind-mount, Docker doesn’t touch the permissions of the directory that’s being mounted in, which I’m guessing is the problem here.