博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用 docker-compose 批量创建机器
阅读量:6707 次
发布时间:2019-06-25

本文共 3459 字,大约阅读时间需要 11 分钟。

docker-compose 与 Dockerfile

config 目录:

使用 docker-compose 批量创建机器

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

你可能感兴趣的文章
2017 Material design 第四章第二节《单位和尺寸》
查看>>
2017 Material design 第一章第三节《Material特性》
查看>>
iOS开发笔记(三):消息传递与转发机制
查看>>
Python缓存技术
查看>>
Metal入门(使用Metal画一个三角形)
查看>>
浅谈 iOS 应用启动过程
查看>>
Clang 之旅—[翻译]添加自定义的 attribute
查看>>
零基础学习Web开发的入门需要掌握哪些?
查看>>
慎用System.nanoTime()
查看>>
2017 移动端 iOS 年终工作总结-纯干货请自备酒水
查看>>
Android小知识-剖析OkHttp中的任务调度器Dispatcher
查看>>
switch的python实现
查看>>
Hybris UI的Route(路由)实现
查看>>
iOS探索:RunLoop本质、数据结构以及常驻线程实现
查看>>
算法的时间复杂度
查看>>
iOS独立开发者使用Bmob第三方后台服务初探
查看>>
共享适合移动端的“拾色器”插件
查看>>
《Java编程思想》笔记09------异常处理
查看>>
CPU发生异常到生成Crash Log的过程
查看>>
pyqt5中动画的使用
查看>>