Docker-compose安装redis-cluster

安装过程:

[root@localhost redis]# pwd
/data/redis
[root@localhost redis]# mkdir 700{1..6}
[root@localhost redis]# mkdir 700{1..6}/data  ##这个目录和下边yml文件的volumes对应
[root@localhost redis]# ls 
7001  7002  7003  7004  7005  7006  docker-compose.yml

文件 docker-compose.yml 内容:
----------------------------
version: '3'

services:
 redis1:
  image: publicisworldwide/redis-cluster
  network_mode: host
  restart: always
  volumes:
   - /data/redis/7001/data:/data
  environment:
   - REDIS_PORT=7001

 redis2:
  image: publicisworldwide/redis-cluster
  network_mode: host
  restart: always
  volumes:
   - /data/redis/7002/data:/data
  environment:
   - REDIS_PORT=7002

 redis3:
  image: publicisworldwide/redis-cluster
  network_mode: host
  restart: always
  volumes:
   - /data/redis/7003/data:/data
  environment:
   - REDIS_PORT=7003

 redis4:
  image: publicisworldwide/redis-cluster
  network_mode: host
  restart: always
  volumes:
   - /data/redis/7004/data:/data
  environment:
   - REDIS_PORT=7004

 redis5:
  image: publicisworldwide/redis-cluster
  network_mode: host
  restart: always
  volumes:
   - /data/redis/7005/data:/data
  environment:
   - REDIS_PORT=7005

 redis6:
  image: publicisworldwide/redis-cluster
  network_mode: host
  restart: always
  volumes:
   - /data/redis/7006/data:/data
  environment:
   - REDIS_PORT=7006
----------------------------
[root@k8s-m2 redis]# docker-compose up -d 
Creating redis_redis1_1 ... done
Creating redis_redis5_1 ... done
Creating redis_redis4_1 ... done
Creating redis_redis3_1 ... done
Creating redis_redis6_1 ... done
Creating redis_redis2_1 ... done 
[root@k8s-m2 redis]# docker-compose ps 
     Name                   Command               State   Ports
---------------------------------------------------------------
redis_redis1_1   /usr/local/bin/entrypoint. ...   Up           
redis_redis2_1   /usr/local/bin/entrypoint. ...   Up           
redis_redis3_1   /usr/local/bin/entrypoint. ...   Up           
redis_redis4_1   /usr/local/bin/entrypoint. ...   Up           
redis_redis5_1   /usr/local/bin/entrypoint. ...   Up           
redis_redis6_1   /usr/local/bin/entrypoint. ...   Up     

// 随便进入一个节点
[root@k8s-m2 redis]# docker exec -ti d3a904cc0d5a bash 
root@k8s-m2:/data# redis-cli --cluster create 192.168.1.100:7001 192.168.1.100:7002 192.168.1.100:7003 192.168.1.100:7004 192.168.1.100:7005 192.168.1.100:7006 --cluster-replicas 1
... 期间输入 'yes' ... 等待完成.