思路: 1、创建相应目录 2、创建配置文件 3、编写compose文件 4、运行
mkdir -p /opt/redis/data
vim /opt/redis/redis.conf
bind 0.0.0.0
daemonize yes
port 6379
requirepass Sutpc@123
dir /data
dbfilename dump.rdb
save 900 1
save 300 10
save 60 10000
appendonly yes
appendfilename appendonly.aof
appendfsync everysec
vim /opt/redis/redis-compose.yml
version: '3'
services:
redis:
image: redis
container_name: redis
command: redis-server /usr/local/etc/redis/redis.conf
restart: always
volumes:
- /opt/redis/data:/data
- /opt/redis/redis.conf:/usr/local/etc/redis/redis.conf
ports:
- 16379:6379
cd /opt/redis && docker-compose -f redis-compose.yml up -d
|