じゃこぴーのぶらり

ぼちぼちいこか。

備忘録:VagrantとVirtualBoxとは??

VagrantVirtualBoxとは??

仮想環境を整えてその中でアプリを作成してみたいと思い、仮想環境を作成。いろいろ調べてみたんだけど、なかなかVagrantVirtualBoxの関係が掴めない、そして調べても忘れてしまうので、まとめる。

VirtualBox

使用しているパソコン上に仮想環境を作るためのソフト。これでMacOS上にWindowsLinuxの環境も作成できる。

Vagrant

VirtualBoxを簡単に動かすためのコマンドライン

VirtualBoxだけでも仮想環境は作れちゃうけど、Vagrantという管理者がいるとよりは角売るよね。って感じ。

Vagrantの使い方

注意:VagrantVirtualBoxはインストールしておくこと。

Boxの取得

BoxのURLは「vagrant box」とかで調べると出てくる。

  • Boxの取得
$ vagrant add box {boxの名前} {BoxのURL}
  • Boxの保管先
$ cd ./.vagrant.d/boxes

仮想環境の初期化

一つのBoxを取得するとここからそれぞれ複数の環境を作ることができる。

$ cd {仮想環境を作成するディレクトリ}
$ vagrant init {boxの名前}
$ vagrant up

vagrant up」でハマった!

$ vagrant up

No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.

解決策:新しいvagrantをインストール。

仮想環境にログイン

$ vagrant ssh