Docker- Redis

博文目录

文章目录


说明

Docker Hub Redis

数据卷 数据卷印射在容器内的路径
redis /data
容器内的路径 说明
/data 数据目录
/data/redis.conf 配置文件

前置

GitHub 找一份 redis.conf 配置文件, 放到卷 redis 中, 按需修改

shell 复制代码
# bind 127.0.0.1 # 解除只允许环回地址访问的限制
daemonize no # 修改为yes会使docker使用配置文件方式启动redis失败
save 900 1 # 如果上个900秒内有超过1次写操作,则保存快照
save 300 10
save 60 10000
requirepass Mrv587.. # 密码

命令

shell 复制代码
docker pull redis:7.2.4
shell 复制代码
docker volume create redis
shell 复制代码
# 创建并运行容器, 在后面加 redis-server /data/redis.conf 指向要使用的配置文件
docker run -d --name redis -p 6379:6379 -e TZ=Asia/Shanghai -v redis:/data redis:7.2.4 redis-server /data/redis.conf
shell 复制代码
# 查看日志
docker logs redis
# 跟踪日志
docker logs -f redis
docker logs --follow redis
# 查看最后10条日志
docker logs --tail 10 redis
# 查看最近10分钟的日志
docker logs --since 10m redis
shell 复制代码
# 进入容器并执行 bash
docker exec -it redis bash
# 退出容器
exit

# 进入客户端
redis-cli
# 认证与鉴权
auth Mrv587..
# 退出客户端
exit

# 直接从主机进入客户端
docker exec -it redis redis-cli
相关推荐
hello_2507 小时前
动手模拟docker网络-bridge模式
网络·docker·桥接模式
小醉你真好9 小时前
15、Docker Compose 安装ELK + Filebeat单机版
elk·docker·jenkins
我真的是大笨蛋9 小时前
Redis的String详解
java·数据库·spring boot·redis·spring·缓存
Gss77711 小时前
Docker 公有仓库使用、Docker 私有仓库(Registry)使用总结
docker·容器
暴富奥利奥11 小时前
完成docker方式的ros环境配置
linux·学习·docker·容器
zhengzizhe12 小时前
Redssion出现attempt to unlock lock, not locked by current thread by node id
redis
海海思思13 小时前
解决Docker "exec format error":架构不匹配问题分析
docker·容器
帅帅梓14 小时前
docker网络
网络·docker·php
Lv-D-J15 小时前
mac下Docker安装nacos
docker
兜兜风d'15 小时前
redis字符串命令
数据库·redis·缓存