Vagrant使用教程

VirtualBox下载地址:https://www.virtualbox.org/wiki/Downloads

Vagrant下载地址:https://developer.hashicorp.com/vagrant/install#Windows

Vagrant镜像下载地址:https://app.vagrantup.com/boxes/search

新建一个文件夹

D:\vagrant\centos7

生成centos/7 Vagrantfile

vagrant init centos/7

创建并启动虚拟机

vagrant up

连接虚拟机

vagrant ssh

重启虚拟机

vagrant reload

Vagrantfile

Vagrant.configure("2") do |config|

  # 使用CentOS 7的官方Vagrant box
  config.vm.box = "centos/7"

  # 设置固定ip
  config.vm.network "private_network", type: "static", ip: "192.168.33.10"

  # 设置虚拟机内部的主机名
  config.vm.hostname = "centos7-vm"

  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    # 设置VirtualBox界面上显示的虚拟机名称
    vb.name = "centos7-vm"
    vb.memory = "1024"
    vb.cpus = 2
  end
  
end

你可能感兴趣的:(工具使用教程,vagrant)