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
相关推荐
goehou5 小时前
Redis 挂掉之后,数据能恢复到哪一步
redis·持久化·aof·rdb
飞奔的瓜牛7 小时前
运维工程师 Redis 日常巡检清单与实战注意事项
运维·数据库·redis
lambo mercy8 小时前
04Docker_Container_容器
docker
IT规划师8 小时前
Redis 核心机制 | 发布订阅:Pub_Sub 与 Sharded PubSub
redis·.net
Wellijohn18 小时前
Docker 瘦身、手写 MCP、异步并发:被问得最多的 12 个问题,一次答完
python·docker·mcp
隔窗听雨眠18 小时前
KWDB容器化部署的形态选择与参数细节
docker·时序数据库·kwdb
Flynn Liang21 小时前
AI Agent Redis 生产踩坑实录:13 类故障的根因、复现与调优
数据库·人工智能·redis·缓存·ai agent·故障分析
SeanQhl1 天前
openEuler 下 Docker 镜像操作与多阶段构建瘦身
docker·容器·镜像·openeuler·dockerfile
新*1 天前
ES 7.17 三节点 Docker 集群的自动备份:从 NFS 被拦住到用 ACL 根治权限
运维·elasticsearch·docker·slm·快照备份
Wellijohn1 天前
Docker 镜像从 1.2GB 压到 180MB:按这个顺序改,别一上来就 multistage
docker