我正在尝试运行官方最新的redis docker镜像,位于以下位置:
https://hub.docker.com/_/redis
我想在自定义配置文件中传递它。
为了测试,我从这里下载了示例配置文件:
https://redis.io/topics/config
我将文件存储在:
C:/Users//redis/config/redis.config
我将目录切换到redis/config文件夹(在powershell中),并执行以下命令:
docker run -it --rm --name redis --net redis -v ${pwd}:/config redis redis-server redis.conf我得到了以下错误:
Fatal error, can't open config file '/data/redis.conf': No such file or directory我也尝试过这个命令:
docker run -it --rm --name redis --net redis -v ${PWD}/config:/etc/redis/ redis redis-server C:\Users\<username>\redis\config\redis.conf这给了我一个类似的错误:
Fatal error, can't open config file '/data/C:\Users\<username>\redis\config\redis.conf': No such file or directory在我看来,它似乎是在containers \data目录中查找本地配置文件...
我不是应该从本地机器的文件结构中传递它吗?
如何从windows执行此命令,以使本地conf由容器化的机器加载。
发布于 2021-11-10 00:43:03
您可能希望将单个文件挂载为卷:
我假设您的config文件实际上是:C:/Users/redis/config/redis.config
> cd C:/Users/redis
> docker run -it --rm --name redis --net redis -v config/redis.config:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf您的文件C:/Users/redis/config/redis.config被引用为config/redis.conf的相对路径,因为当前工作目录为C:\Users\redis。redis映像的构建遵循以下约定:redis-server位于path上,并使用.conf文件的参数运行。
https://stackoverflow.com/questions/69905515
复制相似问题