利用容器制作轻量级虚拟机

首先定义一个Dockerfile 安装虚拟机基础软件
vim  Dockerfile
FROM centos:7
RUN yum install -y \
    vim bash-com* openssh-clients openssh-server iproute cronie;\
    yum group install -y "Development Tools";yum clean all;\
    localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV LANG=zh_CN.UTF-8

使用docker-compose管理工具批量制作虚拟机

vim docker-compose.yml

version: '3.8'
services:
  slb:
    build: .
    image: centos7-sshd
    privileged: true            #开启容器特权
    command: /usr/sbin/init     #linux的第一个进程
    hostname: slb
    container_name: slb
    networks:
      xiaochou:
  tomcat1:
    image: centos7-sshd
    container_name: tomcat1
    privileged: true
    command: /usr/sbin/init
    hostname: tomcat1
    networks:
      xiaochou:
  tomcat2:
    image: centos7-sshd
    container_name: tomcat2
    privileged: true
    command: /usr/sbin/init
    hostname: tomcat2
    networks:
      xiaochou:
  mysql-master:
    image: centos7-sshd
    container_name: mysql-master
    privileged: true
    command: /usr/sbin/init
    hostname: mysql-master
    networks:
      xiaochou:
  mysql-slave:
    image: centos7-sshd
    container_name: mysql-slave
    privileged: true
    command: /usr/sbin/init
    hostname: mysql-slave
    networks:
      xiaochou:
  ansible:
    image: centos7-sshd
    container_name: ansible
    privileged: true
    command: /usr/sbin/init
    hostname: ansible
    networks:
      xiaochou:
networks:
  xiaochou:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值