0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Vagrant入門④:Vagrantの設定

Posted at

Vagrantfileで仮想マシンに設定できること

変数名 説明
config.vm.box 仮想マシンで利用するBOX名
config.vm.box_url 仮想マシンで利用するBOXのURL
config.vm.hostname 仮想マシンに設定するホスト名
config.vm.provider 仮想マシンの操作をするのに利用するプロバイダー名
config.vm.provision 仮想マシン作成時のプロビジョニング方法
config.vm.synced_folder ホストとゲスト間で共有するフォルダ

config.vm.box

Discover Vagrant Boxesで公開されているBox名を記述。
ローカルで対象のBoxを所持していればそれを使用し、所持していなければクラウドから取得をする。

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
end

config.vm.hostname

作成するマシンのホスト名を変更したい場合に記述。
centos/7のデフォルトではlocalhostとなっていました。
今回はhogeで設定。

Vagrant.configure("2") do |config|
  config.vm.hostname = "hoge"
end

config.vm.synced_folder

ホストとゲスト間で共有するフォルダを設定。
config.vm.synced_folder "ホスト側のPATH", "ゲスト側のPATH"
PATHの指定には相対パスを使用できる。

Vagrant.configure("2") do |config|
  config.vm.synced_folder "", "/vagrant"
end

参照

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?