## Install Ubuntu containers on Archlinux using LXC Install the _lxc_ and the _debootstrap_ packages: ``` # pacman -Sy lxc debootstrap ``` ### Install an Ubuntu container I will install Ubuntu 14.04 LTS. Therfore, I will use the _trusty_ release. If you want to install Ubuntu 12.04 LTS, use the _precise_ release. I create an LXC container named _ubuntu-14_ with the release _trusty_ and the architecture _amd64_: ``` # lxc-create --name=ubuntu-14 --template=ubuntu -- --release trusty --arch amd64 ``` ### Setup the network Install the _libvirt_ package because we need the _virsh_ program. Also, we will need _ebtables_ and _dnsmasq_ for the default NAT/DHCP networking. [(*)](https://wiki.archlinux.org/index.php/libvirt#Server) ``` # pacman -Sy libvirt ebtables dnsmasq ``` Start and enable the _libvirtd_ daemon. ``` # systemctl start libvirtd # systemctl enable libvirtd ``` Print the virtual network configuration _default_ provided by _libvirtd_. ```xml # virsh net-dumpxml default default f9f9128b-8183-4c2c-af56-23cd52100d3a ``` Edit the file /var/lib/lxc/ubuntu-14/config to set-up the network configuration of the container: ``` lxc.net.0.type = veth lxc.net.0.flags = up lxc.net.0.name = eth0 lxc.net.0.link = virbr0 ``` Setup the _virb0_ interface: ``` # virsh net-start default ``` ### Start the Ubuntu container Start the Ubuntu container as follow: ``` # lxc-start --name ubuntu-14 ``` Get the IP of the Ubuntu container: ``` # lxc-ls -f ubuntu-14 -F IPV4 ``` You can stop the Ubuntu container as follow: ``` # lxc-stop --name ubuntu-14 ``` ### Set a static IP for the container Edit the default virtual network provided by _libvirtd_ to restrict the DHCP range from 192.168.122.2-192.168.122.254 to 192.168.122.10-192.122.254. ``` # virsh net-edit default ``` as follow: ```xml default bd881c3e-406f-40bb-84ed-b09e68f210e2 ``` Restart the _libvirtd_ daemon: ``` # systemctl restart libvirtd ``` Stop the the _trusty_ container: ``` # lxc-stop --name ubuntu-14 ``` Add the following line in the file /var/lib/lxc/ubuntu-14/config: ``` lxc.net.0.ipv4.address = 192.168.122.2/24 ``` Restart the _ubuntu-14_ container. ### Connect to the container ``` # ssh ubuntu@192.168.122.2 ``` Use the password _ubuntu_ to connect.