[英]Persist data across redis container
So I have been trying to persist the data of a redis container.所以我一直在尝试持久化 redis 容器的数据。 I created a host shared folder called /redis-volume and am trying to store the data from redis into it.
我创建了一个名为 /redis-volume 的主机共享文件夹,并试图将 redis 中的数据存储到其中。
I was trying to persist data across redis container in docker-compose version 3. And this is what finally worked.我试图在 docker-compose 版本 3 中的 redis 容器中保留数据。这就是最终奏效的方法。 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 .在主机上的 /redis-volume 中,您将能够找到一个名为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!希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.