vagrant筆記
Table of Contents
vagrant筆記
Vagrant Official Site
Place Where You Can Download And Upload Box
1 General
1.1 Path
下載的box預設放在~/.vagrant.d/boxes裡
guest machine的data放的地方根據VM設定而不同可開啟VirtualBox查看,VirtualBox預設是在~/VirtualBox\ VMS
1.2 Shared Folder
guest machine的/vagrant將會自動mount到host machine的放Vagrantfile的那個folder
此功能需要guest machine的Box的VB guest additions版本與VM中的一樣
若出現錯誤則需要更新box或用這個非官方的plugin: https://github.com/dotless-de/vagrant-vbguest
2 Uninstall
2.1 REMOVING THE VAGRANT PROGRAM
rm -rf /Applications/Vagrant |
2.2 REMOVING USER DATA
rm -rf ~/.vagrant.d |
3 Command
https://www.vagrantup.com/docs/cli/
vagrant init #create Vagrantfile in current folder |
3.1 halt vs destory vs box remove
vagrant halt: 將machine關機
vagrant destroy: 將machine關機,且將該machine移除,但box還留著
vagrant box remove: 移除box
4 Provision
example: 安裝apache server and 將DocumentRoot指向/vagrant when provision
bootstrap.sh
#!/usr/bin/env bash |
Vagrantfile
Vagrant.configure("2") do |config| |
記得run vagrant reload –provision
5 Network
5.1 Port Forwarding
Vagrant.configure("2") do |config| |
then run vagrant reload
5.2 Private Network
Vagrant.configure("2") do |config| |
Render by hexo-renderer-org with Emacs 25.2.1 (Org mode 8.2.10)