LoginSignup
5
7

More than 5 years have passed since last update.

OS Xで始めるVagrant

Last updated at Posted at 2014-05-28

Vagrantの使い方をメモ
VirtualBoxはインストールしてある状態でお願いします。

環境

  • OS X 10.9.3
  • Vagrant 1.6.2
  • VirtualBox 4.3.10

Vagrantをインストールする

www.vagrantup.comからインストーラをダウンロードし、インストールする。

Vagrantfileを作る

Vagrantfileはゲストマシンの環境を記述したファイルであり、以下のコマンドで作成できる。

$ vagrant init [title] [url]

titleはローカルに保存するBoxの名前なので、任意。
urlはここを参照し、イメージを選択する。

例えばこんな感じに。

$vagrant init CentOS6.5x86_64 https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box

そして、

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

ゲストマシンを起動する。
新しいBoxを利用する際にはダウンロードのための時間がかかる。

完了したら、

$ vagrant ssh

でアクセスできる、簡単。

ゲストマシンの状態を管理

以下,ちょっとしたゲストマシン状態管理のためのコマンドです。

ゲストマシンの状態を表示

$ vagrant status

vagrantで作成した仮想マシンの状態を表示する。

ゲストマシンのリロード

$ vagrant reload

Vagrantfileを書き換えたときなど,設定の反映するためのリロード。

ゲストマシンのサスペンド

$ vagrant suspend

仮想マシンをサスペンド状態にする。
リジュームするにはvagrant upvagrant resumeする。

ゲストマシンの停止

$ vagrant halt

ゲストマシンを停止させる。
このコマンドを使用する前に,ゲストマシン内でシャットダウンのためのコマンドを実行する必要がある。
強制シャットダウンオプションとして--forceがある。

起動するためにはvagrant upする。

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7