一、下载redis 镜像
docker pull redis
二、创建数据卷映射路径、配置redis.conf
mkdir -p /usr/local/myredis/conf
vim redis.conf
# redis.conf
appendonly yes
-
配置内容可以参考 https://github.com/redis/redis/blob/unstable/redis.conf
-
启用内存过渡分配
#修改配置
vim /etc/sysctl.conf
# 增加如下配置,否则启用redis的时候会有警告
vm.overcommit_memory=1
- 执行
sysctl -p
三、创建redis容器
# -v /usr/local/myredis/conf:/usr/local/etc/redis 挂载配置文件
# -v -v /usr/local/myredis/data:/data 挂载数据
# redis-server /usr/local/etc/redis/redis.conf 以配置文件的形式启动redis
docker run -d -v /usr/local/myredis/conf:/usr/local/etc/redis -v /usr/local/myredis/data:/data --name myredis --restart=always -p 6379:6379 redis redis-server /usr/local/etc/redis/redis.conf
标签:myredis,Redis,redis,local,etc,usr,conf,Docker,安装
From: https://www.cnblogs.com/bangbangzoutianya/p/17765523.html