1. 准备redis.conf文件
设置密码
requirepass 1Ng4oLeCVoc2ceOG
设置db数量,默认是16个
databases 64
设置日志位置
logfile "/var/log/redis/redis.log"
设置数据存放位置
dir /data
2. docker-compse
version: '3'
services:
redis:
image: redis:6.2.6-alpine
ports:
- "6379:6379"
volumes:
- ./work/components/redis/log/redis.log:/var/log/redis/redis.log:rw
- ./work/components/redis/config/redis.conf:/home/redis/redis.conf:rw
- ./work/components/redis/data:/data:rw
restart: always
privileged: true
command:
/bin/sh -c "redis-server /home/redis/redis.conf"
运行docker-compose up -d