1. Vagrant功能:
Vagrant usesOracle’s VirtualBox to build configurable, lightweight, and portable virtual machines dynamically..
【Vagrant 使用Oracle VM VirtualBox 动态创建和配置轻量级的,可重现的,便携的虚拟机环境。】
2. Vagrant下载:
3. Vagrant安装:
3.1. 下载并安装Oracle VM VirtualBox: 例如在Windows环境下,需要安装VirtualBox
https://www.virtualbox.org/wiki/Downloads
3.2. 下载并安装最新版本的Vagrant:
http://downloads.vagrantup.com/
[注]在 Windows and Mac OS X,
https://www.virtualbox.org/wiki/Downloads
3.2. 下载并安装最新版本的Vagrant:
http://downloads.vagrantup.com/
[注]在 Windows and Mac OS X,
vagrant
命令应该自动添加到环境变量PATH
. 但是在其他操作系统下, 你必须手动添加/opt/vagrant/bin
到环境变量PATH。
4. Vagrant命令
Vagrant安装完成之后,我们就可以从命令行通过vagrant命令来进行操作。vagrant 常用命令如下:
vagrant box add <name> <url>
vagrant box list
vagrant box remove <name>
vagrant box repackage <name>
vagrant init [box-name] [box-url]
vagrant up [vm-name] [--[no-]provision] [-h]
vagrant destroy [vm-name]
vagrant suspend [vm-name]
vagrant reload [vm-name]
vagrant resume [vm-name]
vagrant halt [vm-name]
vagrant status [vm-name]
vagrant package [vm-name] [--base name] [--output name.box][--include one,two,three] [--vagrantfile file]
vagrant provision [vm-name]
vagrant ssh [vm-name] [-c command] [-- extra ssh args]
vagrant ssh-config [vm-name] [--host name]
vagrant box list
vagrant box remove <name>
vagrant box repackage <name>
vagrant init [box-name] [box-url]
vagrant up [vm-name] [--[no-]provision] [-h]
vagrant destroy [vm-name]
vagrant suspend [vm-name]
vagrant reload [vm-name]
vagrant resume [vm-name]
vagrant halt [vm-name]
vagrant status [vm-name]
vagrant package [vm-name] [--base name] [--output name.box][--include one,two,three] [--vagrantfile file]
vagrant provision [vm-name]
vagrant ssh [vm-name] [-c command] [-- extra ssh args]
vagrant ssh-config [vm-name] [--host name]
5. Vagrantfile
任何Vagrant工程下都有一个Vagrantfile, 就像makefile一样,Vagrantfile用来配置vagrant的行为所创建虚拟机的信息,下面是一个基本的Vagrantfile:
Vagrant::Config.run do |config|# Setup the boxconfig.vm.box = "my_box" end