Init——创建Vagrantfile文件
格式:
vagrant init [options] [name [url]]
通过创建初始的Vagrantfile文件(如果不存在的话),将当前目录初始化为vagrant环境。
userdeMacBook-Pro:~ user$ vagrant init -h Usage: vagrant init [options] [name [url]] Options: --box-version VERSION Version of the box to add 添加的box的版本 -f, --force Overwrite existing Vagrantfile 复写已经存在的Vagrantfile文件 -m, --minimal Use minimal Vagrantfile template (no help comments). Ignored with --template 使用最小化的Vagrantfile模版(这种模版是没有帮助注释的),使用它将会忽视--template标签的使用 --output FILE Output path for the box. '-' for stdout box的输出路径,如果FILE为'-',意味输出的Vagrantfile将送到stdout --template FILE Path to custom Vagrantfile template 定制Vagrantfile模版的路径 -h, --help Print this help 打印帮助信息
如果给出第一个参数,它将在创建的流浪者文件中预填充config.vm.box
如果给出第二个参数,它将在创建的Vagrantfile中预填充config.vm.box_url
例子:
创建基本的Vagrantfile:
$ vagrant init hashicorp/precise64
创建最小化的Vagrantfile文件 (无注释):
$ vagrant init -m hashicorp/precise64
创建新的Vagrantfile文件, 将当前路径下的覆盖:
$ vagrant init -f hashicorp/precise64
为来自指定box URL的执行box创建Vagrantfile文件:
$ vagrant init my-company-box https://boxes.company.com/my-company.box
创建一个Vagrantfile文件,对box进行版本限制:
$ vagrant init --box-version '> 0.1.5' hashicorp/precise64