11
10

More than 5 years have passed since last update.

vagrantで遊んでみた

Posted at

仮想マシンのフロントエンドvagrant。すごく流行っているみたいなのでとりあえず動かしてみた。

結論

めちゃくちゃ楽。特にGUIが要らなければすごく便利。あとはvagrantのレイヤじゃないけど、仮想マシンを使うことでどこまでパフォーマンスが落ちるかが気になるところかな。

環境

ホストマシンOS:Ubuntu 13.10 x86_64
仮想マシンOS:Ubunutu 12.04 x86_64

vagrantのセットアップ

とりあえず試してみるのに必要なパッケージはvirtualboxとvagrantだけ。やってないけど仮想マシンエンジンはVMWareやAmazon EC2でもいけるらしい。

sudo apt-get install virtualbox
sudo apt-get install vagrant

仮想マシンのセットアップ・起動・終了

起動終了にまつわる基本的なコマンドは以下のとおり。

vagrant box add precise64 http://files.vagrantup.com/precise64.box
                            # 仮想マシンのテンプレート(box)を取得
vagrant init precise64      # boxから仮想マシン作成
vagrant up                  # 仮想マシン起動
vagrant ssh                 # 仮想マシンにログイン(exitでログアウト)
vagrant suspend             # 仮想マシン一時停止
vagrant resume              # 仮想マシン再開
vagrant halt                # 仮想マシン停止
vagrant destroy             # 仮想マシン削除

共有フォルダ

デフォルトで、vagrant initしたホストマシンのディレクトリと、ゲストマシンのホームディレクトリ(/home/vagrant)が共有設定されている。とても便利。

カスタマイズした仮想マシンの共有

仮想マシンのカスタマイズができて共有したくなったら、vagrant packageでテンプレート(box)化できる。
できたtemplate.boxをwebサーバとかにあげといて、他の人にvagrant box addしてもらえば環境構築完了。
な、なんて楽なんだ。。。

11
10
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
11
10