Shells | Development Environments | Git | Virtural Environments | Markdown and Editors | Programming Languages | Task Management | Specialized Tools
Creating computing and development environments will be an essential skill for processing and manipulating data with tools and code. Unfortunately, consistently getting software installed on a your computer and correctly setting up the environments can take away weeks of your productive time.
Virtual environments can provide a useful solution for automating the creating and management of your computing environment and development workflow. Lets setup a simple machine.
- Install vagrant.
- Install VirtualBox is a recommended provider. Other virtual machine providers do exist.
When you create a VM with vagrant, it will create a Vagrantfile in your current directory as well as a hidden directory (.vagrant). Vagrant only allows one virtual machine configuration per directory. You will want to organize your VMs:
mkdir -p /boxes/workshop;cd /boxes/workshop
Initialize a virtual machine. ubuntu/trusty64 is one default image. A list of other virtual machine images can be found here.
vagrant init ubuntu/trusty64
Start up the virtual machine.
vagrant up
Then
vagrant ssh
You should be able to connect to the machine.
- If you're running Hyper-V and VirtualBox, and you're experiencing crashes when you try to start a VM, you may need to turn off Hyper-V (which exclusively locks use of CPU for virtualization).
- If you can't run vagrant ssh, Add
C:\Program Files\Git\usr\binto your PATH, which includesssh.
The Vagrantfile will contain some settings you can adjust for memory, networking, etc. Two customizations you may consider making if working with your VM long-term:
-
- Enable a synced folder. This will allow you to edit code/files from editors in your host OS.
-
- Fix DNS to use the same as your host OS instead of its own.
# Important, you must run vagrant in an admin shell if you want symlinks to work correctly.
# i.e., for npm install to work properly, you must have vagrant provision the machine in admin cmd prompt.
config.vm.synced_folder "C:/dev", "/code"
config.vm.synced_folder "C:/projects", "/projects"
config.vm.provider :virtualbox do |vb|
# fix crappy dns
# https://serverfault.com/questions/453185/vagrant-virtualbox-dns-10-0-2-3-not-working
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
endIn virtualbox, VMs typically have four ways to set up the network:
- Network Address Translation (NAT), which is the default,
- Bridged,
- Internal network
- Host Only (Recommended).
Unlike the first virtual machine, you cannot use the default mode, because there will be no way for the workshop VM to talk to the node VM. Instead, you much choose between bridged or host-only.
Private networking (Host-only) is the recommended setting for Linux/Mac/Windows 10. Bonus: You can use hard-coded ip address in your scripts. Uncomment the following line in Vagrantfile:
config.vm.network "private_network", ip: "192.168.33.10"Then run, vagrant reload.
- Create a new VM with vagrant in /boxes/mysql.
- Enable private networking, but with a different ip address.