Docker hosted redis losing data

Viewed 890

I am running standalone Redis using docker-hub image with volume for
persistent storage(--appendonly yes), however after a while all the keys from the Redis are disappearing.
I haven't set the EXPIRE time for any of the keys. Runnning the docker with following command :

docker run  -p 6379:6379 -v redis-vol:/data -d redis redis-server --appendonly yes


Can anyone please let me know what might be going wrong?

Thank you.

1 Answers

Yeah you will be losing the keys each time you are creating a new container, although you have a permanent storage 'volume'. The thing you are missing is to set the environment variables ALLOW_EMPTY_PASSWORD=yes and DISABLE_COMMANDS=FLUSHDB,FLUSHALL,CONFIG If you are using docker-compose file you can simply add them as:

redis:
image: 'bitnami/redis:latest'
environment:
  - ALLOW_EMPTY_PASSWORD=yes
  - DISABLE_COMMANDS=FLUSHDB,FLUSHALL,CONFIG
container_name: haproxy_redis_auth_redis
ports:
  - "6379:6379"
volumes:
  - redis-data:/bitnami/redis/data

In so case, do not forget to make your application depends on redis service

application:
build: .
depends_on:
  - db
  - redis

I had the same issue which been fixed after I took a look here: https://hub.docker.com/r/bitnami/redis/

Related