Docker实战:docker compose 搭建Redis

1、配置文件准备

redis 配置文件:https://pan.baidu.com/s/1YreI9_1BMh8XRyyV9BH08g

2、创建目录并赋权

mkdir -p /home/docker/redis/data /home/redis/logs /home/redis/conf
chmod -R 777 /home/docker/redis/data*
chmod -R 777 /home/docker/redis/logs*

3、redis.conf 配置文件

cd /home/docker/redis/conf
vim redis.conf
// 内容见上面“redis 配置文件”

4、编辑docker-compose-redis.yml文件

vim docker-compose-redis.yml

version: '3.0'
services:
  redis:
    image: redis:6.2.6
    container_name: redis
    restart: always
    privileged: true
    environment:
      - TZ=Asia/Shanghai
      - LANG=en_US.UTF-8
    #定义挂载点
    volumes:
      - /home/docker/data/redis/conf/redis.conf:/etc/redis/redis.conf
      - /home/docker/data/redis:/data
      - /home/docker/data/redis/logs:/logs
    ports:
      - 6379:6379
    command: ["redis-server","/etc/redis/redis.conf"]

5、启动Redis

docker-compose -f docker-compose-redis.yml up -d

你可能感兴趣的:(Docker,Linux,Redis,docker,redis,容器)