rediSearch enable persistence in docker container.

Can you please describe how to get persistence for a container?

docker run -d -p 6379:6379 -v /Users/test/Documents/repositories/hack/redis.conf:/usr/local/etc/redis/redis.conf -v /Users/test/Documents/repositories/hack:/data --name search redislabs/redisearch:latest

redis.conf content

loadmodule ./
appendonly yes
aof-use-rdb-preamble yes

By default, redis saves its database to the dump.rdb file in the current directory. You can specify dir and dbfilename (either on the command line, or in the configuration file) to have redis save the db to $dir/$dbfilename. You can piece this together with the appropriate -v arguments to docker to allow persistence.

Also by default you’ll need to send a SAVE command to persist your database. Again, look in the redis.conf file for more information on how you can make the database automatically persist: You can also use AOF, depending on your requirements.

Mark Nunberg | Senior Software Engineer
Redis Labs - home of Redis


If you are able to describe a working example that starting and stopping the container will not lose data it would be helpful.
I tried to bind the data directory but I don’t see anything written in it when I start and stop the container after having indexed some data
docker run -d -p 6379:6379 -v /Users/test/Documents/repositories/hack:/data --name search redislabs/redisearch:latest

I’m having the same issue using docker-compose. Stopping and re-launching the container causes all ft:whatever keys not being read from disk (I tried using both rdb only and rdb+aof with rdb preamble). Instead redis standard keys gets restored properly. Inspecting the rdb/aof files I can see the redisearch ft: keys, but I don’t have the knowledge to determine if the file is somehow corrupted or not.
This is the redisearch container I’m defining in my docker-compose:

        image: redislabs/redisearch:1.6.10
            - "6379:6379"
            - type: volume
              source: redis
              target: /data
        command: ["redis-server", "--loadmodule", "/usr/lib/redis/modules/", "--appendonly", "yes", "--aof-use-rdb-preamble", "yes"]

@kind84 I just tested it, my docker compose file is this:

image: redislabs/redisearch:1.6.10
- “6379:6379”
- ./redis:/data
command: [“redis-server”, “–loadmodule”, “/usr/lib/redis/modules/”, “–appendonly”, “yes”, “–aof-use-rdb-preamble”, “yes”]

I added data to RediSearch and also searched to make sure it is working> FT.CREATE idx SCHEMA t TEXT
OK> FT.ADD idx doc1 1.0 FIELDS t foo
OK> FT.SEARCH idx foo

  1. (integer) 1
  2. “doc1”
    1. “t”
    2. “foo”

Then I stopped and restart the container and the data is still there and I get it on my search results. Maybe you have a more specific example that I can try to reproduce your issue?