如何使用Vagrant创建虚拟机
时间:2019-08-20 17:58:09 来源:igfitidea点击:
Vagrant
创建保存Vagrant文件的目录。
mkdir -p ~/vagrant_boxes/Single_VM/poc_box
创建一个名为“Vagrantfile”的文件
cd ~/vagrant_boxes/Single_VM/poc_box vi Vagrantfile
内容如下:
# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| # In 'config' block, set variable 'vb' where defining desired Vagrant Provider and VM specs. config.vm.provider "virtualbox" do |vb| vb.name = "webserver01" vb.memory = 1024 vb.cpus = 2 end #now using main 'config' block, defining OS,Hostname and Virtual Box network type. config.vm.box = "centos/8" config.vm.hostname = "webserver01" config.vm.network "private_network", ip: "192.168.33.10" end
运行下面的在VirtualBox中创建单节点虚拟机
vagrant up