仮想マシンの状態確認と削除

メモ:  Category:blog

作成した仮想マシンの状態確認と削除を行ってみます。

仮想マシンの状態確認

vagrant で作成した仮想マシンの状態を確認するには、次のコマンドを実行します。このコマンドは、 vagrant で作成した複数の仮想マシンに対応します。

$ vagrant global-status
id       name        provider   state    directory
-----------------------------------------------------------------------------
1e39505  homestead-7 virtualbox poweroff C:/Users/hoge/Homestead

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date (use "vagrant global-status --prune" to prune invalid
entries). To interact with any of the machines, you can go to that
directory and run Vagrant, or you can use the ID directly with
Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"

仮想マシン単体の状態を確認したい場合、作成した仮想マシンの環境(vagrantfileがあるディレクトリ)へ移動し次のコマンドを実行します。

$ vagrant status

仮想マシンの削除

仮想マシンを削除するには、 global-status コマンドで確認し削除したい ID を指定して次のコマンドを実行します。

$ vagrant destroy [ID]
    homestead-7: Are you sure you want to destroy the 'homestead-7' VM? [y/N] y
==> homestead-7: Destroying VM and associated drives...

vagrantfileがあるディレクトリへ移動し、カレントの仮想マシンのみを削除したい場合は次のコマンドを実行します。

$ vagrant destroy

bluenote by BBB