当前位置: 首页 > news >正文

docker 安装redis 7.4.2并挂载配置文件以及设置密码

文章目录

  • docker 安装redis 7.4.2
    • 下载 redis
    • 如果你喜欢使用最新的版本
    • 创建挂载redis 配置文件
    • 创建容器

docker 安装redis 7.4.2

截至2025年2月21日,Redis的最新稳定版本是 7.4.2。

下载 redis

如果你想拉取Redis的特定版本(例如最新的稳定版本 7.4.2),可以使用以下命令

docker pull redis:7.4.2

如果你喜欢使用最新的版本

如果你想使用Redis的最新稳定版本(由latest标签指向)

docker pull redis:latest

拉取镜像后,你可以使用以下命令查看本地已下载的Docker镜像

docker images

在这里插入图片描述

创建挂载redis 配置文件

在 /docker/redis 目录下创建两个子目录:conf 和 data

mkdir -p /docker/redis/{conf,data}

切换到 /docker/redis/conf 目录,方便后续操作。

cd docker/redis/conf

在 /docker/redis/conf 目录下创建一个空的 redis.conf 文件

touch redis.conf

使用 vim 编辑器打开 redis.conf 文件,进行配置

vim redis.conf

redis.conf 配置信息

bind 0.0.0.0protected-mode yesport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize nosupervised nopidfile /docker/redis/redis_6379.pidloglevel noticelogfile ""databases 16always-show-logo yessave 900 1
save 300 10
save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbrdb-del-sync-files nodir ./replica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-diskless-load disabledrepl-disable-tcp-nodelay noreplica-priority 100acllog-max-len 128lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush nolazyfree-lazy-user-del nooom-score-adj nooom-score-adj-values 0 200 800appendonly yesappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512
hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128
zset-max-ziplist-value 64hll-sparse-max-bytes 3000stream-node-max-bytes 4096
stream-node-max-entries 100activerehashing yesclient-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60hz 10dynamic-hz yesaof-rewrite-incremental-fsync yesrdb-save-incremental-fsync yesjemalloc-bg-thread yes

退出编辑

创建容器

docker run -p 6379:6379 --name redis -v /docker/redis/conf:/etc/redis/redis.conf -d redis --requirepass "123456"

在这里插入图片描述

如果是云服务器,记得配置安全组
在这里插入图片描述

http://www.lryc.cn/news/542175.html

相关文章:

  • 计算机毕业设计SpringBoot+Vue.js在线教育系统(源码+文档+PPT+讲解)
  • Linux-C-函数栈-SP寄存器
  • vi的基本使用
  • clickhouse--表引擎的使用
  • LeetCode刷题零碎知识点整理
  • GLTFLoader.js和OrbitControls.js两个 JavaScript 文件都是 Three.js 生态系统中的重要组成部分
  • 大厂数据仓库数仓建模面试题及参考答案
  • angular简易计算器
  • 谈谈 ES 6.8 到 7.10 的功能变迁(3)- 查询方法篇
  • 16、Python面试题解析:python中的浅拷贝和深拷贝
  • 游戏引擎学习第119天
  • 爬虫解析库:Beautiful Soup的详细使用
  • OpenHarmony-4.基于dayu800 GPIO 实践(2)
  • 【C++设计模式】观察者模式(1/2):从基础到优化实现
  • 《机器学习数学基础》补充资料:欧几里得空间的推广
  • 在配置PX4中出现的问题2
  • 2025-2-24-4.9 单调栈与单调队列(基础题)
  • python绘图之swarmplot分布散点图
  • 数据库之MySQL——事务(一)
  • Linux学习笔记之文件
  • LLM学习
  • Classic Control Theory | 13 Complex Poles or Zeros (第13课笔记-中文版)
  • 给小米/红米手机root(工具基本为官方工具)——KernelSU篇
  • 【MySQL】表的增删查改(CRUD)(上)
  • 测试用例的Story是什么?
  • 15.4 FAISS 向量数据库实战:构建毫秒级响应的智能销售问答系统
  • Golang笔记——Interface类型
  • 如何查看图片的原始格式
  • FreiHAND (handposeX-json 格式)数据集-release >> DataBall
  • 【Rust中级教程】2.8. API设计原则之灵活性(flexible) Pt.4:显式析构函数的问题及3种解决方案