version: '3'
services:
redis:
image: redis
restart: always
hostname: redis #指定容器hostname
container_name: redis
privileged: true
ports:
- 6379:6379
environment:
TZ: Asia/Shanghai #timeZone 时区
volumes:
# 在当前目录下创建/data /conf /logs
- ./data:/data
- ./conf:/etc/redis/redis.conf
- ./logs:/logs
command: [ "redis-server", "/etc/redis/redis.conf" ]
在当前目录(/compose/redis/)下创建data,conf,logs目录,用作数据卷映射
下载redis的配置文件,放到conf目录下
http://download.redis.io/redis-stable/redis.conf
docker-compose up -d