码迷,mamicode.com
首页 > 其他好文 > 详细

docker安装redis 5.0.7并挂载外部配置和数据

时间:2019-12-02 19:24:03      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:mode   topic   配置   name   权限   指定容器名称   持久化   res   异常   

环境

CentOS Linux release 7.7.1908 (Core)

拉取redis 5.0.7 镜像

docker  pull redis:5.0.7

创建挂载目录

mkdir -p /home/app/redis/conf
mkdir -p /home/app/redis/data

下载redis.conf

redis.conf 地址

技术图片

进入目录并下载redis.conf

cd /home/app/redis/conf
wget https://raw.githubusercontent.com/antirez/redis/5.0/redis.conf

修改redis.conf

  注释符号 #
  1. 注释 bind 127.0.0.1  
  2. protected-mode yes 修改成 protected-mode no
  3. 添加 requirepass yourpassword (注:不添加则可以无密码访问)
  注:
     步骤1和步骤的2目的是为了远程连接redis,如果只需本地访问就无需修改

创建启动容器

docker run --restart=always  -d --privileged=true -p 6379:6379 -v /home/app/redis/conf/redis.conf:/etc/redis/redis.conf -v /home/app/redis/data:/data --name redis redis:5.0.7 redis-server /etc/redis/redis.conf --appendonly yes

参数解释

--restart=always                                            -> 开机启动容器,容器异常自动重启
-d                                                          -> 以守护进程的方式启动容器
--privileged=true                                           -> 提升容器内权限
-p 6379:6379                                                -> 绑定宿主机端口
-v /home/app/redis/conf/redis.conf:/etc/redis/redis.conf    -> 映射配置文件
-v /home/app/redis/data:/data                               -> 映射数据目录
--name redis                                                -> 指定容器名称
--appendonly yes                                            -> 开启数据持久化

docker安装redis 5.0.7并挂载外部配置和数据

标签:mode   topic   配置   name   权限   指定容器名称   持久化   res   异常   

原文地址:https://www.cnblogs.com/roinbi/p/11972160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!