创建本地路径
## 数据存放目录
mkdir -p /docker/redis/data
## 配置文件存放目录
mkdir -p /docker/redis/conf
根据自己的 Docker 镜像,拉取一份 Redis 的配置文件。
wget https://raw.githubusercontent.com/antirez/redis/5.0.7/redis.conf -O /docker/redis/conf/redis.conf
## 修改配置文件
## 允许远程连接
#bind 127.0.0.1
protected-mode no
## 持久化
appendonly yes
## 密码
requirepass `password`
启动Redis
docker run --name redis-serve -p 6379:6379 -v /docker/redis/data:/data -v /docker/redis/conf/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf