1、编写docker-compose.yml
version: "3.1"
services:
redis:
image: redis:4
restart: always
command: redis-server /usr/local/redis/redis.conf
ports:
- 6379:6379
volumes:
- ./data:/usr/local/redis/data
- ./redis.conf:/usr/local/redis/redis.conf
2、编写redis.conf
requirepass 123456
daemonize no
bind 0.0.0.0
appendonly yes
注:
需安装docker和docker-compose
docker-compose.yml和redis.conf在同一个目录下