当前位置:网站首页>Docker 安装 Redis-5.0.12,详细步骤
Docker 安装 Redis-5.0.12,详细步骤
2022-06-24 19:34:00 【Nice2cu_Code】
Docker安装Redis-5.0.12
一、拉取镜像
docker pull redis:5.0.12
二、查看镜像
docker images

成功拉取
三、修改配置文件
因为 redis 默认配置你会发现只能够本地连接,不能进行远程访问,使用 Redis Desktop Manager连接都会报错,因此需要手动挂载 redis 配置文件。
创建文件夹
mkdir /opt/docker_redis进入目录
cd /opt/docker_redis下载
redis.conf文件wget http://download.redis.io/redis-stable/redis.conf文件授权
chmod 777 redis.conf修改配置信息
vim redis.conf注释掉 bind 127.0.0.1,解除本地连接限制
注意:在vim编辑器中,可以使用
/关键字快速定位关键字的位置
修改 protected-mode,保护模式,限制为本地访问,修改后解除保护模式

修改 daemonize,修改为守护进程

修改密码
在 redis.conf 中找到 requirepass foobared

保存修改后的配置文件
四、启动容器
docker run -p 6379:6379 --name myredis -v /opt/docker_/redis/redis.conf:/etc/redis/redis.conf -v /opt/docker_/redis/data:/data -d redis:5.0.12 redis-server /etc/redis/redis.conf --appendonly yes --requirepass 设置的密码
指令分析:
-p 6379:6379 端口映射:前表示主机部分,:后表示容器部分。
––name myredis 指定该容器名称,查看和进行操作都比较方便。
-v 挂载文件或目录 :前表示主机部分,:后表示容器部分。
-d redis 表示后台启动redis
redis-server /etc/redis/redis.conf
以配置文件启动redis,加载容器内的conf文件,最终找到的是挂载的目录/usr/local/docker/redis.conf
–appendonly yes 开启redis 持久化
–requirepass 输入设置的密码
五、进入容器
检查容器是否运行
docker ps
进入容器
docker exec -it myredis /bin/bash进入Redis客户端
redis-cli
输入密码

边栏推荐
- 为什么有的程序员能力一般却能拿到好offer?
- Short video mall system, how does scroll view adapt to the remaining height of the page
- cv2导包时报Could not find a version that satisfies the requirement cv2 (from versions: none)
- 印刷行业的ERP软件的领头羊
- The logic of "Ali health" has long changed
- MySQL gets fields and comments by indicating
- How does flutter use the online transcoding tool to convert JSON to model
- leetcode-201_ 2021_ 10_ seventeen
- C language - keyword 1
- Several classes of manual transactions
猜你喜欢

I really can't do it. After 00, I collapsed and wanted to leave

【OpenCV 例程200篇】209. HSV 颜色空间的彩色图像分割

leetcode_ 191_ 2021-10-15

leetcode:45. 跳跃游戏 II【经典贪心】

YGG 近期游戏合作伙伴一览

关于自动控制原理资料更新

壹沓科技签约七匹狼,助力「中国男装领导者」数字化转型

Resolving the conflict problem of the flutter Library

是真干不过00后,给我卷的崩溃,想离职了...

I really want to send a bunch of flowers
随机推荐
leetcode:55. Jumping game [classic greed]
Jianmu continuous integration platform v2.5.0 release
leetcode:515. 在每个树行中找最大值【无脑bfs】
Drag drag drag
Opengauss kernel: simple query execution
Information update on automatic control principle
Two implementation methods of stack
磁盤的結構
Servlet details
Reduce the pip to the specified version (upgrade the PIP through pycharm, and then reduce it to the original version)
leetcode:55. 跳跃游戏【经典贪心】
socket(2)
Datakit agent realizes unified data aggregation in LAN
You are using pip version 21.1.2; however, version 22.1.2 is available
Flutter 库冲突问题解决
为什么有的程序员能力一般却能拿到好offer?
leetcode:45. 跳跃游戏 II【经典贪心】
Publicity of the second batch of shortlisted enterprises! Annual Top100 smart network supplier selection
权限想要细化到按钮,怎么做?
leetcode-201_ 2021_ 10_ seventeen