Installing Vagrant and host-manager with LXC on Ubuntu 18.04

This took me quite a while and failed tries to figure out:

apt-get update
apt-get install lxc
dpkg -i vagrant_2.1.2_x86_64.deb
vagrant plugin install vagrant-lxc
vagrant plugin install vagrant-hostmanager

You should probably check if a newer version has been released, if you miss any dependencies try to install the vagrant-lxc packages from Ubuntu before the .deb package.

Create a project folder containing the following Vagrantfile:

Vagrant.configure("2") do |config| = "debian/stretch64"
   config.hostmanager.enabled = true
   config.hostmanager.manage_host = true
   config.hostmanager.manage_guest = true

   config.vm.define "ns1" do |ns1|
     ns1.vm.hostname = "ns1.local"

   config.vm.define "ns2" do |ns2|
     ns2.vm.hostname = "ns2.local"


Now run

vagrant up

To bring the environment online, and verify name-resolving and connectivity:

# ping ns1.local -c 4
PING ns1.local ( 56(84) bytes of data.
64 bytes from ns1.local ( icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from ns1.local ( icmp_seq=2 ttl=64 time=0.065 ms
64 bytes from ns1.local ( icmp_seq=3 ttl=64 time=0.066 ms
64 bytes from ns1.local ( icmp_seq=4 ttl=64 time=0.081 ms

--- ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.052/0.066/0.081/0.010 ms

Connect to one of the machines with:

# vagrant ssh ns1

Enjoy 😉

Dette indlæg blev udgivet i Development, Linux, Vagrant, Workstation. Bogmærk permalinket.

Skriv et svar