docker compose 方式
- vim docker-compose.yaml
version: '3'
services:
redis:
image: redis:7-alpine
restart: always
volumes:
# Mount the redis data directory to the container.
- /data/redis:/data
# Set the redis password when startup redis server.
command: redis-server --requirepass 123456
environment:
TZ: Asia/Shanghai
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
ports:
- "6379:6379"
- 启动
docker compose up -d