我是靠谱客的博主 聪明铃铛,最近开发中收集的这篇文章主要介绍vagrant 使用,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

vagrant 文档: http://docs.vagrantup.com/v2/getting-started/index.html

1. 初识vagrant

从 http://www.vagrantup.com/downloads 站点下载相应版本的vagrant并安装

安装完成后会自动将"vagrant"加入系统的环境变量中.

vagrant支持的provider有virtualbox, vmware, aws等,下面的介绍中使用的是virtualbox, virtualbox免费并支持多个平台.

1.1 用vagrant来启动一台32位的ubuntu虚拟机

➜  ~  vagrant init hashicorp/precise32
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
➜  ~  vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'hashicorp/precise32' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'hashicorp/precise32'
    default: URL: https://vagrantcloud.com/hashicorp/precise32
==> default: Adding box 'hashicorp/precise32' (v1.0.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/hashicorp/precise32/version/1/provider/virtualbox.box
==> default: Successfully added box 'hashicorp/precise32' (v1.0.0) for 'virtualbox'!
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Setting the name of the VM: hsgroot_default_1399458969510_99441
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /home/hsgroot

1.2 登陆刚创建的虚拟机

vagrant ssh

1.3 注销虚拟机

vagrant destroy

2 建立vagrant 工程

创建vagrant工程时会自动生成配置文件Vagrantfile. Vagrantfile是描述Project中的虚拟机的类型以及如何配置这些虚拟机.

最后

以上就是聪明铃铛为你收集整理的vagrant 使用的全部内容,希望文章能够帮你解决vagrant 使用所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(64)

评论列表共有 0 条评论

立即
投稿
返回
顶部