Vagrantfile介绍

本文介绍了Vagrantfile的用途和配置方法,包括如何指定虚拟机类型、配置网络、同步文件夹等,并提供了SSH设置的说明。

Vagrantfile 流浪者的说明书

描述需要一个怎样的开发环境:什么类型的虚拟机,怎样配置,预装哪些软件

Vagrantfile应该在版本控制工具中,团队共享,使得环境一致

加载顺序:内置  -> 和box一起打包的  ->  ~/.vagrant.d下的 -> project dir下的

  1. Built-in default Vagrantfile that ships with Vagrant. This has default settings and should never be changed by any user of Vagrant.
  2. Vagrantfile packaged with the box that is to be used for a given machine.
  3. Vagrantfile in your Vagrant home directory (defaults to ~/.vagrant.d). This lets you specify some defaults for your system user.
  4. Vagrantfile from the project directory. This is the Vagrantfile that you'll be modifying most of the time.
配置版本:为向前兼容,VAGRANTFILE_API_VERSION = "2"
机器设置:
config.vm.box 某个已安装的box的名字
         .box_url 已配置好的box的位置,如果没有安装在本地,up时会先获取之
         .graceful_halt_retry_count 正常关机的重试次数,默认为3      
         .graceful_halt_retry_interval 正常关机的重试间隔时间,默认为1s
         .guest vm os的类型 linux
         .hostname vm的hostname,默认为nil
         .network 连接网络类型
         .provider vm提供者
         .synced_folder 主客同步文件夹
         .usable_port_range vm解决端口冲突时的可用端口范围  默认2200..2250
       
SSH配置:
config.ssh.host|port|private_key_path|username|guest_port|keep_alive|max_tries|timeout|forward_agetnt|forward_x11
           see: http://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html
Vagrant自身配置: config.vagrant.host

转载于:https://my.oschina.net/jingxing05/blog/158267

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值