vagrant 入门

基础镜像

centos7
http://pan.baidu.com/s/1o7BSmoU
centos6
http://pan.baidu.com/s/1o81Zb9C

ubuntu
http://pan.baidu.com/s/1pLzVhnP

添加本地box

vagrant box add 自定义你的box名称  box路径

vagrant box add my_first_box D:/centos-7.0-x86_64.box

查看已添加的box

vagrant box list

删除box

vagrant box remove your_box_name

vagrant虚拟机优化

虚拟机名称

config.vm.hostname = "test"
虚拟机主机名

vb.name = "ubuntu_test"
配置虚拟机内存

vb.memory = "512"
配置虚拟机CPU

vb.cpus = 1
完整示例 先复制一份Vagrantfile为Vagrantfile.bak作为备份 Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "centos"
  config.vm.network "forwarded_port", guest:80, host:80
  config.vm.network "forwarded_port", guest:8080, host:8080
  config.vm.synced_folder "/Users/andy/data", '/data', :smb => true
  config.vm.network "private_network", ip: "192.168.100.126"
  config.vm.hostname = "test"

  config.vm.provider "virtualbox" do |vb|
    vb.name = "ubuntu_test"
    vb.memory = "512"
    vb.cpus = 1
  end
end