docker-compose 运行 redis

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)

创建数据目录

# mkdir -pv /data/apps/redis/{conf,logs,data}
# chown -R 999.999 /data/apps/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

 

posted @ 2023-04-06 12:37  小吉猫  阅读(258)  评论(0编辑  收藏  举报