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
相关推荐
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
分布式存储与RustFS3 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
IT大白鼠3 天前
Redis 系列 · 第 01 篇——认知入门:Redis 是什么
redis·nosql
彧azz3 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
玉&心3 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing3 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
赵文宇(温玉)3 天前
CoreDNS的hosts插件的缺行配置导致k8s集群异常
容器·kubernetes·rancher
guo_wen_qiang3 天前
上传本地镜像到harbor中
docker·容器·持续部署
羑悻的小杀马特3 天前
Dockerfile 全景指南:从入门编写dockerfile到生产环境镜像优化实战,一步步带你从啃透制作指令到镜像制作落地!
docker·dockerfile·镜像制作
BianHuanShiZhe3 天前
docker常见命令
docker