docker 安装 redis

拉取最新的Redis镜像

powershell 复制代码
docker pull redis:7.0.2

mkdir -p /home/tools/redis/{conf,data}

启动一个临时Redis容器

powershell 复制代码
docker run -d --name redis-temp redis:7.0.2

将容器内的默认配置文件复制到宿主机

powershell 复制代码
docker cp redis-temp:/usr/local/etc/redis/redis.conf /home/tools/redis/conf/

如果复制不到

powershell 复制代码
安装  wget
sudo yum install wget

# 下载 Redis 7.0.2 的默认配置文件
wget https://raw.githubusercontent.com/redis/redis/7.0.2/redis.conf -O /home/tools/redis/conf/redis.conf

停止并删除临时容器

powershell 复制代码
docker rm -f redis-temp

配置文件修改

powershell 复制代码
# 注释掉这行,允许远程连接(或者改为 bind 0.0.0.0)
# bind 127.0.0.1 -::1
bind 0.0.0.0
# 关闭保护模式,允许远程连接
protected-mode no

# 设置访问密码(务必修改为一个强密码)
requirepass 123456

# 开启AOF持久化
appendonly yes

# 设置日志级别
loglevel notice

运行 Redis 容器:

powershell 复制代码
docker run -d \
  --name redis \
  -p 6379:6379 \
  -v /home/tools/redis/conf/redis.conf:/etc/redis/redis.conf \
  -v /home/tools/redis/data:/data \
  redis:7.0.2 \
  redis-server /etc/redis/redis.conf
相关推荐
dyj0958 小时前
Dify - (一)、本地部署Dify+聊天助手/Agent
人工智能·docker·容器
Nice_Fold11 小时前
Kubernetes DaemonSet、StatefulSet与Service(自用笔记)
笔记·容器·kubernetes
虹科网络安全12 小时前
艾体宝产品|深度解读 Redis 8.4 新增功能:原子化 Slot 迁移(上)
数据库·redis·bootstrap
虹科网络安全15 小时前
艾体宝新闻|Redis 月度更新速览:2026 年 3 月
数据库·redis·缓存
Java后端的Ai之路16 小时前
Kubernetes是什么?(小白入门版)
云原生·容器·kubernetes·教程
y = xⁿ16 小时前
Redis八股学习日记:布隆过滤器
数据库·redis·学习
木雷坞16 小时前
视觉算法环境 Docker 镜像拉取失败排查
运维·人工智能·docker·容器
瀚高PG实验室17 小时前
安全版V4.5版本docker容器license过期问题处理步骤
安全·docker·容器·瀚高数据库
java_logo17 小时前
SiYuan 思源笔记 Docker 部署终极指南:Windows+Linux 双平台
windows·笔记·docker·思源笔记·思源笔记部署·docker部署思源笔记·思源笔记文档