@H_502_1@我想在docker上运行的Redis服务器上设置密码.我跟随了https://registry.hub.docker.com/_/redis/的instcruction:
@H_502_1@1.我创建了一个包含Dockerfile的文件夹,其中包含:
@H_502_1@
FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server","/usr/local/etc/redis/redis.conf" ]
@H_502_1@2.我添加了一个redis.conf文件:
@H_502_1@
requirepass thepassword
@H_502_1@我使用以下方法构建了图像:
@H_502_1@
docker build -t ouruser/redis .
@H_502_1@我开始了容器:
@H_502_1@
docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server --appendonly yes
@H_502_1@redis服务器没有任何密码!我不懂为什么.最佳答案
运行命令:
@H_502_1@
docker run --name my-redis -p 0.0.0.0:6379:6379 -d ouruser/redis redis-server --appendonly yes
@H_502_1@使用redis-server覆盖Dockerfile中定义的CMD – 依赖是,因此您的conf文件将被忽略.只需将conf文件的路径添加到run命令中:
@H_502_1@
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
@H_502_1@或者,设置入口点脚本或向CMD指令添加–appendonly yes.