redis docker-使用数据创建一个容器 [英] redis docker - create a container with data

查看:82
本文介绍了redis docker-使用数据创建一个容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个带有初始数据的redis容器。
在图像的文档中,我可以使用一个卷挂载到 / data
我的问题是:redis能够从中读取并加载数据吗?
如果是这样,我挂载的目录应该是什么?
我(非常幼稚)尝试放置一个名称为 someFile的文件,希望redis知道将其保存为键 someFile,并将文件内容作为数据保存。

I want to run a redis container with initial data in it. In the documentation of the image, I can use a volume to mount to /data. My question is: will redis be able to read the data from it and load it? And if so, what should be in the directory that I mount? My (very naive) attempt was to put a file with name "someFile" and hopefully redis will know to save it with key "someFile" and the content of the file as the data. Obviously it didn't work.

任何帮助将不胜感激。

推荐答案

您可以第一次运行redis容器,将一个空目录设置为数据卷,然后使用redis CLI填充redis数据。
停止容器后,数据目录将包含一个有效的Redis数据集。

You can run the redis container one first time setting an empty directory as the data volume and populate the redis data using the redis CLI. Once you stop the container, the data directory will contain a working redis data set.

如果您运行另一个指定相同目录的容器实例,则Redis将使用

If you run another container instance specifying the same directory, redis will use that data.

请注意,您将需要配置redis以便将数据持久存储到文件系统中(请检查 https://redis.io/topics/persistence

Please be aware that you will need to configure redis in order to persist data to the filesystem accordingly (check https://redis.io/topics/persistence)

这篇关于redis docker-使用数据创建一个容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆