Vagrant コマンドメモ

Vagrantの基本コマンドをメモとして残す。

# Vagrant

## 確認 : `$ vagrant status`
vagrantでの現状ステータスを表示します。 
※初期ステータス : **poweroff**

```console
$ vagrant status
  
  Current machine states:

  default                   poweroff (virtualbox)

  The VM is powered off. To restart the VM, simply run `vagrant up`
```

## 起動 : `$ vagrant up`
vagrantを起動する。 
ステータス : **running**

```console
$ vagrant status
  Current machine states:

  default                   poweroff (virtualbox)

  The VM is powered off. To restart the VM, simply run `vagrant up`
  

$ vagrant up
  Bringing machine 'default' up with 'virtualbox' provider...
  // 省略


$ vagrant status
  Current machine states:

  default                   running (virtualbox)

  The VM is running. To stop this VM, you can run `vagrant halt` to
  shut it down forcefully, or you can run `vagrant suspend` to simply
  suspend the virtual machine. In either case, to restart it again,
  simply run `vagrant up`.

```



## ログイン : `$ vagrant ssh`
vagrantにsshでログインする。 
vagrant起動`$ vagrant up`後に実行する。 
ステータス : **running**

```console
$ vagrant status
  
  Current machine states:

  default                   running (virtualbox)

  The VM is powered off. To restart the VM, simply run `vagrant up`
  

$ vagrant ssh
  Last login: Mon Jan 15 16:39:43 2018 from 10.0.2.2

```


## 一時停止 : `$ vagrant suspend`
vagrantを一時停止する。 
vagrantからログアウト後に実行する。 
ステータス : **saved**

```console
$ vagrant status
  Current machine states:

  default                   running (virtualbox)

  The VM is running. To stop this VM, you can run `vagrant halt` to
  shut it down forcefully, or you can run `vagrant suspend` to simply
  suspend the virtual machine. In either case, to restart it again,
  simply run `vagrant up`.


$ vagrant suspend
  ==> default: Saving VM state and suspending execution...
  

$ vagrant status
  Current machine states:

  default                   saved (virtualbox)

  To resume this VM, simply run `vagrant up`.
```

## 再起動 : `$ vagrant resume`
vagrantの状態を一時停止から再起動する。 
一時停止`$ vagrant suspend`の状態において、再起動が実行可能。

```console
$ vagrant status
  Current machine states:

  default                   running (virtualbox)

  The VM is running. To stop this VM, you can run `vagrant halt` to
  shut it down forcefully, or you can run `vagrant suspend` to simply
  suspend the virtual machine. In either case, to restart it again,
  simply run `vagrant up`.
  

$ vagrant suspend
  ==> default: Saving VM state and suspending execution...


$ vagrant status
  Current machine states:

  default                   saved (virtualbox)

  To resume this VM, simply run `vagrant up`.


$ vagrant resume
  ==> default: Resuming suspended VM...
  ==> default: Booting VM...
  ==> default: Waiting for machine to boot. This may take a few minutes...
  ==> default: Machine booted and ready!
  ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
  ==> default: flag to force provisioning. Provisioners marked to run always will still run.


$ vagrant status
  Current machine states:

  default                   running (virtualbox)

  The VM is running. To stop this VM, you can run `vagrant halt` to
  shut it down forcefully, or you can run `vagrant suspend` to simply
  suspend the virtual machine. In either case, to restart it again,
  simply run `vagrant up`.
```


## 停止 : `$ vagrant halt`
vagrantを停止する。 
vagrantからログアウト後に実行する。 
ステータス : **poweroff**

```console
$ vagrant status
  Current machine states:

  default                   saved (virtualbox)

  To resume this VM, simply run `vagrant up`.
  

$ vagrant halt
  ==> default: Discarding saved state of VM...
  

$ vagrant status
  Current machine states:

  default                   poweroff (virtualbox)

  The VM is powered off. To restart the VM, simply run `vagrant up`
```