docker-compose 运行 redis

时间:2022-09-01 01:29:04

redis.conf

logfile /data/redis/logs/redis.log
dir /data/redis/data
bind 0.0.0.0
requirepass 123456

UID

# docker run --rm -it redis:7.0.10 id redis
uid=999(redis) gid=999(redis) groups=999(redis)

docker-compose.yaml

version: '3.9'

services:

  redis:
    image: "redis:7.0.10"
    container_name: redis
    restart: always
    environment:
    - TZ=Asia/Shanghai
    networks:
      - redis
    ports:
    - "6379:6379"
    volumes:
    - /data/apps/redis/conf:/data/redis/conf
    - /data/apps/redis/data:/data/redis/data
    - /data/apps/redis/logs:/data/redis/logs
    command: "redis-server /data/redis/conf/redis.conf"

networks:
  redis:
    driver: bridge

运行redis

# docker-compose up -d