基于docker 部署redis

1、拉取镜像

复制代码
docker pull redis:latest

如果拉取失败可以尝试下配置镜像源,具体参考如下,目前暂可以使用

Docker切换镜像源-CSDN博客

2、创建配置文件

mkdir /usr/local/redis/conf

vim redis.conf

复制代码
bind 0.0.0.0

#protected-mode no
port 6379
tcp-backlog 511
# 登录密码
requirepass 123456
timeout 0
tcp-keepalive 300
daemonize no
pidfile /var/run/redis_6379.pid
loglevel notice
# 默认没有日志
logfile ""
# 指定日志输出位置
# logfile /var/log/redis/redis-server.log
databases 30
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
appendonly yes
appendfilename "appendonly.aof"
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
hz 10
aof-rewrite-incremental-fsync yes

3、执行镜像

复制代码
docker run  -p 6379:6379 --name redis --restart=always \
     -v /usr/local/redis/conf/redis.conf:/etc/redis/redis.conf \
     -v /usr/local/redis/data:/data \
     -d redis redis-server /etc/redis/redis.conf \
     --appendonly yes --requirepass 123456
相关推荐
我是咸鱼不闲呀3 分钟前
力扣Hot100系列20(Java)——[动态规划]总结(下)( 单词拆分,最大递增子序列,乘积最大子数组 ,分割等和子集,最长有效括号)
java·leetcode·动态规划
清水白石00812 分钟前
深入解析 LRU 缓存:从 `@lru_cache` 到手动实现的完整指南
java·python·spring·缓存
礼拜天没时间.18 分钟前
深入Docker架构——C/S模式解析
linux·docker·容器·架构·centos
猫头虎23 分钟前
如何使用Docker部署OpenClaw汉化中文版?
运维·人工智能·docker·容器·langchain·开源·aigc
符哥200825 分钟前
C++ 进阶知识点整理
java·开发语言·jvm
会周易的程序员34 分钟前
openplc runtimev4 Docker 部署
运维·c++·物联网·docker·容器·软件工程·iot
Sayuanni%337 分钟前
初阶_多线程1(线程含义与关键属性)
java
程序媛徐师姐38 分钟前
Java基于微信小程序的模拟考试系统,附源码+文档说明
java·微信小程序·java模拟考试系统小程序·模拟考试微信小程序·模拟考试系统小程序·模拟考试小程序·java模拟考试小程序
疯狂敲代码的老刘1 小时前
JDK 1.6到25 全版本网盘合集 (Windows + Mac + Linux)
java·linux·windows·macos·jdk
夕除1 小时前
js--15
java·jvm·spring