LoginSignup
1
1

More than 5 years have passed since last update.

vagrant で VM 起動

Last updated at Posted at 2014-11-06

debian7 を Vagrant で動かしたときのお手軽手順。
Vagrant 等々のインストールは終わった段階から。
box ファイルは予め手元にダウンロード済み(debian-7.1.0.box)。

こんな状態でスタート。

$ ls
debian-7.1.0.box

まずは Vagrantfile を生成。

$ vagrant init

VM の名前は適当に、my-debian-7.1.0 で。
IP アドレスはお好みで。
Vagrantfile は、最低限下記 2 項目だけ指定しておけば。

Vagrantfile
config.vm.box = "my-debian-7.1.0"
config.vm.network :private_network, ip: "192.168.33.10"

VM 追加。

$ vagrant box add 'my-debian-7.1.0' ./debian-7.1.0.box

追加されてるのを確認。

$ vagrant box list
my-debian-7.1.0 (virtualbox, 0)

VM 起動。

$ vagrant up

起動したら、vagrant ユーザでログイン可能。

$ vagrant ssh

vagrant-ssh でもいいんですが、Host 側の ./ssh/config に登録しておくと便利かと。
今回は my って名前で。

$ vagrant ssh-config --host my >> ~/.ssh/config

以降、my て名称でアクセスできます。

$ ssh my
1
1
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
1
1