So I have been trying to persist the data of a redis container. I created a host shared folder called /redis-volume and am trying to store the data from redis into it.
I was trying to persist data across redis container in docker-compose version 3. And this is what finally worked. Please let me know if this is the right way to do it
container_name: redis_db
command: redis-server --appendonly yes
image: redis
ports:
- "6379:6379"
volumes:
- ./redis-volume:/data
Inside the /redis-volume on the host you will be able to find a file called appendonly.aof . This is what persists data. Also while restarting the container you will be able to find a line like this if you look closely.
redis_db | 1:M 08 Jun 2020 19:40:28.024 * DB loaded from append only file: 0.000 seconds
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.