本文共 3459 字,大约阅读时间需要 11 分钟。
config 目录:
Dockerfile 文件信息
FROM centos:latestMAINTAINER peter "ttone2@vip.qq.com"RUN groupadd -r redis && useradd -r -g redis redisRUN yum -y update && yum -y install epel-release \&& yum -y install redis && yum -y install wget \&& yum -y install net-tools \&& yum -y install ruby && yum -y install rubygemsRUN wget https://rubygems.org/downloads/redis-3.2.1.gem && gem install -l ./redis-3.2.1.gem \&& rm -f redis-3.2.1.gemCOPY ./config/redis-trib.rb /usr/binCOPY ./config/redis.sh /usr/binRUN mkdir -p /config && chmod 775 /usr/bin/redis.sh && chmod 775 /usr/bin/redis-trib.rb
docker-compose.yaml
version: "3.6"services: redis-master10: image: redis-cluster container_name: redis-master10 working_dir: /config environment: - PORT=6400 ports: - "6400:6400" - "16400:16400" stdin_open: true networks: redis-master: ipv4_address: 172.50.0.10 tty: true privileged: true volumes: ["/home/work/redis-cluster/config:/config"] entrypoint: - /bin/bash - redis.sh redis-master11: image: redis-cluster container_name: redis-master11 working_dir: /config # 启动后的工作目录 environment: - PORT=6401 ports: - "6401:6401" - "16401:16401" stdin_open: true networks: redis-master: ipv4_address: 172.50.0.11 tty: true privileged: true volumes: ["/home/work/redis-cluster/config:/config"] entrypoint: - /bin/bash - redis.sh redis-master12: image: redis-cluster container_name: redis-master12 working_dir: /config environment: - PORT=6402 ports: - "6402:6402" - "16402:16402" stdin_open: true networks: redis-master: ipv4_address: 172.50.0.12 tty: true privileged: true volumes: ["/home/work/redis-cluster/config:/config"] entrypoint: - /bin/bash - redis.sh redis-slave10: image: redis-cluster container_name: redis-slave10 working_dir: /config environment: - PORT=6402 networks: redis-slave: ipv4_address: 172.30.0.10 ports: - "6402:6402" - "16402:16402" stdin_open: true tty: true privileged: true volumes: ["/home/work/redis-cluster/config:/config"] entrypoint: - /bin/bash - redis.sh redis-slave11: image: redis-cluster container_name: redis-slave11 working_dir: /config environment: - PORT=6404 networks: redis-slave: ipv4_address: 172.30.0.11 ports: - "6404:6404" - "16404:16404" stdin_open: true tty: true privileged: true volumes: ["/home/work/redis-cluster/config:/config"] entrypoint: - /bin/bash - redis.sh redis-slave12: image: redis-cluster container_name: redis-slave12 working_dir: /config environment: - PORT=6405 networks: redis-slave: ipv4_address: 172.30.0.12 ports: - "6405:6405" - "16405:16405" stdin_open: true tty: true privileged: true volumes: ["/home/work/redis-cluster/config:/config"] entrypoint: - /bin/bash - redis.shnetworks: # 主节点的网卡信息 redis-master: driver: bridge ipam: driver: default config: - subnet: 172.50.0.0/16 # 从节点的网卡信息 redis-slave: driver: bridge ipam: driver: default config: - subnet: 172.30.0.0/16 redis-test: external: name: mynetwork
转载于:https://blog.51cto.com/laok8/2393363