redis.yml

 

2023-08-03

Docker Compose 配置文件:

1
version: "3.7"
2
3
services:
4
redis:
5
image: bitnami/redis:latest
6
restart: always
7
container_name: "redis"
8
ports:
9
- '6379:6379'
10
environment:
11
- ALLOW_EMPTY_PASSWORD=no
12
- REDIS_PASSWORD=redis的连接密码
13
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
14
volumes:
15
- /data/redis:bitnami/redis/data

REDIS_DISABLE_COMMANDS 变量允许你禁用某些 Redis 命令:

  • FLUSHDB:用于清空当前数据库中的所有 key
  • FLUSHALL:用于清空整个 Redis 服务器上的所有数据库的所有 key

注: volumes 会报错: Can’t open or create append-only dir appendonlydir: Permission denied

1
version: '3'
2
3
services:
4
redis:
5
image: redis:latest
6
restart: always
7
container_name: redis
8
ports:
9
- "6379:6379"
10
volumes:
11
- ./data:/data
12
command: redis-server --appendonly yes --requirepass "mypassword"
13
14
volumes:
15
data:

注: 未测试