Chạy VM trên VirtualBox bằng Vagrant

Ví dụ, tôi muốn run 1 máy ảo centos 7:

Bước 1: Cài đặt VirtualBox: https://www.virtualbox.org/wiki/Downloads

Bước 2: Cài đặt Vagrant: https://developer.hashicorp.com/vagrant/downloads

Bước 3: Tải vagrant box Centos 7 tại: http://www.vagrantbox.es/

Bước 4: Tạo thư mục chứa vagrant box:

 mkdir -p ~/vagrant/centos7

Bước 5: Copy vagrant box download ở bước 3 vào trong thư mục ~/vagrant/centos7

Bước 6:

cd ~/vagrant/centos7
vagrant box add centos-7.0-x86_64.box --name centos7
vagrant init
nano  Vagrantfile

sửa giá trị của config.vm.box thành centos7 như tên đặt ở câu lệnh vagrant box add

Cuối cùng là khởi động VM và SSH:

vagrant up
vagrant ssh

Khi muốn tắt VM:

vagrant halt

Muốn xóa hẳn VM:

vagrant destroy