【问题标题】:How to run Redis on docker with a different configuration file?如何使用不同的配置文件在 docker 上运行 Redis?
【发布时间】:2015-07-28 09:49:00
【问题描述】:

我想在 docker 上运行的 Redis 服务器上设置密码。我已按照https://registry.hub.docker.com/_/redis/ 上的说明进行操作:

1.我创建了一个包含 Dockerfile 的文件夹:

FROM redis  
COPY redis.conf /usr/local/etc/redis/redis.conf  
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] 

2.我添加了一个 redis.conf 文件:

requirepass thepassword

3.我使用以下方法构建图像:

docker build -t ouruser/redis .

4.我启动了容器:

docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server --appendonly yes

redis服务器没有密码!我不懂为什么。

【问题讨论】:

    标签: redis docker dockerfile


    【解决方案1】:

    运行命令:

    docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server --appendonly yes
    

    用redis-server --appendonly yes 覆盖Dockerfile 中定义的CMD,因此您的conf 文件将被忽略。只需将 conf 文件的路径添加到运行命令中即可:

    docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server /usr/local/etc/redis/redis.conf --appendonly yes
    

    或者,设置入口点脚本或将--appendonly yes 添加到 CMD 指令中。

    【讨论】:

      猜你喜欢
      • 2021-10-07
      • 1970-01-01
      • 2014-06-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 2019-11-04
      • 2020-11-28
      相关资源
      最近更新 更多