docker+docker-compose 安装 redis

参考:https://blog.csdn.net/m0_50638181/article/details/123615781

>cd ~/workspace/dockerspace/redis/6379
>mkdir ./{data,logs}
>vi redis.conf
>vi docker-compose.yml

docker-compose up -d

redis.conf 内容;

# ..
port 6379
# ..
requirepass 123456

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

############################## APPEND ONLY MODE ###############################

appendonly yes

# The name of the append only file (default: "appendonly.aof")

appendfilename "appendonly.aof"

添加 docker-compose.yml 内容:

version: '3.3'

services:
  redis:
    image: redis
    restart: always
    hostname: redis
    container_name: redis
    privileged: true
    ports:
      - 6379:6379
    environment:
      TZ: Asia/Shanghai
    volumes:
      - ~/workspace/dockerspace/redis/6379/data:/data
      - ~/workspace/dockerspace/redis/6379/redis.conf:/etc/redis/redis.conf
      - ~/workspace/dockerspace/redis/6379/logs:/logs
    command: ["redis-server","/etc/redis/redis.conf"]

开启终端运行:

docker-compose up -d

Can’t open the log file: Permission denied
chmod 777 logs/

欢迎您的到来,感谢您的支持!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注