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
https://oss.redislabs.com/redisearch/Administration.html#persistence
redis.conf content
loadmodule ./redisearch.so
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:
https://github.com/antirez/redis/blob/unstable/redis.conf. You can also use AOF, depending on your requirements.
Mark Nunberg | Senior Software Engineer
Redis Labs - home of Redis
Email: mark@redislabs.com
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:
redis:
image: redislabs/redisearch:1.6.10
ports:
- "6379:6379"
volumes:
- type: volume
source: redis
target: /data
command: ["redis-server", "--loadmodule", "/usr/lib/redis/modules/redisearch.so", "--appendonly", "yes", "--aof-use-rdb-preamble", "yes"]
@kind84 I just tested it, my docker compose file is this:
redis:
image: redislabs/redisearch:1.6.10
ports:
- “6379:6379”
volumes:
- ./redis:/data
command: [“redis-server”, “–loadmodule”, “/usr/lib/redis/modules/redisearch.so”, “–appendonly”, “yes”, “–aof-use-rdb-preamble”, “yes”]
I added data to RediSearch and also searched to make sure it is working
127.0.0.1:6379> FT.CREATE idx SCHEMA t TEXT
OK
127.0.0.1:6379> FT.ADD idx doc1 1.0 FIELDS t foo
OK
127.0.0.1:6379> FT.SEARCH idx foo
- (integer) 1
- “doc1”
-
- “t”
- “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?