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
相关推荐
lx188548698961 天前
Redis大Key阻塞:单线程CPU100%的致命陷阱
数据库·redis·缓存
正经教主1 天前
【docker基础】第六课:Web应用与数据库容器部署
网络·docker·容器
IT策士1 天前
Redis 从入门到精通:位图、HyperLogLog、GEO
数据库·redis·缓存
IT策士1 天前
Redis 从入门到精通:Python 操作 Redis 进阶
数据库·redis·python
Shacoray1 天前
K8s 中 Ingress 的 HTTPS 证书 如何生成?
容器·https·kubernetes
布局呆星1 天前
Spring Boot + Redis 缓存实战:@Cacheable、序列化踩坑、缓存一致性,一次讲透
spring boot·redis·缓存
开发者联盟league1 天前
使用k8s安装Jenkins
容器·kubernetes·jenkins
Devin~Y1 天前
大厂 Java 面试实战:从 Spring Boot 微服务到 AI RAG 音视频平台全链路解析
java·spring boot·redis·spring cloud·微服务·rag·spring ai
“码”力全开1 天前
突破安防黑盒:基于 Docker 与边缘计算的 AI 视频管理平台,实现 GB28181/RTSP 统一接入与全源码交付二次开发架构解析
人工智能·docker·边缘计算
花间相见1 天前
【AI工作流搭建n8n】—— Docker + PostgreSQL 生产环境部署全攻略:MCP 集成与 Skills 技能实战
人工智能·docker·postgresql