使用docker-compose安装redis

1、编写docker-compose.yml

version: "3.1"
services:
    redis:
        image: redis:4
        restart: always
        command: redis-server /usr/local/redis/redis.conf
        ports:
            - 6379:6379
        volumes:
            - ./data:/usr/local/redis/data
            - ./redis.conf:/usr/local/redis/redis.conf

2、编写redis.conf

requirepass 123456
daemonize no
bind 0.0.0.0
appendonly yes

 

注:

需安装docker和docker-compose

docker-compose.yml和redis.conf在同一个目录下

posted @ 2021-09-07 15:54  孤城丶闭  阅读(864)  评论(0编辑  收藏  举报