Vagrant enables users to create and configure lightweight, reproducible, and portable development environments.
Download Vagrant:
https://www.vagrantup.com
Discover Vagrant Boxes:
https://app.vagrantup.com/boxes/search
Add Ubuntu box:
vagrant box add https://atlas.hashicorp.com/ubuntu/boxes/precise64
Or if you prefer to use Debian:
vagrant box add https://app.vagrantup.com/debian/boxes/stretch64
Initialise the first vm:
mkdir -p ~/Vagrant/vBox01
cd ~/Vagrant/vBox01
vagrant init debian/stretch64
Start vagrant box:
vagrant up
Access box directly:
vagrant ssh
[optional] Initialise second vm:
mkdir -p ~/Vagrant/vBox02
cd ~/Vagrant/vBox02
vagrant init ubuntu/precise64
All downloaded boxes are stored at Mac OS X and Linux under: ~/.vagrant.d/boxes
List all downloaded and local available vagrant boxes:
vagrant box list
Vagrant can more! Some of my own configurations examples aka Vagrantfile-snippets.
Network configuration
Possible network options:
config.vm.network "public_network", type: "dhcp"
config.vm.network "public_network", bridge: 'en7: USB 10/100/1000 LAN', type: "dhcp"
config.vm.network "public_network", bridge: 'en7: USB 10/100/1000 LAN', ip: "192.168.1.201"
Access ports of a vagrant box:
config.vm.network "forwarded_port", guest: 80, host: 8080
On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is not possible to bind to ports below 1024 from applications that are not run by root. So forward port 80 to port 80 will not work.
To list all network interfaces on a MAC System:
vboxmanage list bridgedifs
Other useful commands
Update existing vagrant box:
vagrant box update --box debian/jessie64
SCP from host to vagrant box
To be able to copy files from the host system to the vagrant box without TCP/IP connectivity, you have to install the vagrant-scp plugin.
vagrant plugin install vagrant-scp
scp example:
# get the box id
vagrant global-status
# scp file
vagrant scp package.zip BOX_ID:package.zip
OS X Vagrant Manager
Vagrant Manager tool for OS X allows you to manage your boxes without the terminal.
Leave a Reply