By now you've probably seen some of the hype around containers, the next level of virtualization. Most of the discussion is about Docker containers, and it mostly revolves around application deployment. While, that's mostly the focus of Docker containers, containers can be used for pretty much anything.
Canonical creates a wrapper for the LXC container technology called LXD. With LXD, managing containers is pretty similar to managing VMs, so you can get started quick and easy.
The scope of this how-to is to showcase getting a container setup on Ubuntu 16.04 and communicating on your LAN. The instructions are assuming everything is running off of DHCP and you've already got Ubuntu installed
** Important Note: If you are running your Ubuntu install as a VM you will have to change a setting on the VM's virtual network adapter in order for the container guests to communicate on the network. In Hyper-V you need to Enable MAC address spoofing. In VMWare or VirtualBox you need to enable promiscuous mode.
First of, you need to create a bridge. This turns your Ubuntu Server into a switch so that your containers can access the LAN and pull IPs.
So this is what we need to install for that
Next we need to configure the networking settings.
Or you can use your favorite text editor instead of nano
Remove eth0 (or comment out) from your file
Add a bridge, and include your network interface in the bridge
Save and reboot
Once rebooted `ip addr show` should now show br0 pulling and IP, and eth0 should be listed but no longer pulling an IP
By default, LXD uses a bridge that isn't connected to your LAN. So we're going to swap that bridge for your new bridge.
Change parent: lxdbr0 to
And save
Now create your container. This downloads the container image and sets it up. The image is saved for creating more containers in the future
To view your list of containers and see if they're pulling an IP
To enter bash on your container
See more LXD commands for working with your containers here
https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container-312/
Canonical creates a wrapper for the LXC container technology called LXD. With LXD, managing containers is pretty similar to managing VMs, so you can get started quick and easy.
The scope of this how-to is to showcase getting a container setup on Ubuntu 16.04 and communicating on your LAN. The instructions are assuming everything is running off of DHCP and you've already got Ubuntu installed
** Important Note: If you are running your Ubuntu install as a VM you will have to change a setting on the VM's virtual network adapter in order for the container guests to communicate on the network. In Hyper-V you need to Enable MAC address spoofing. In VMWare or VirtualBox you need to enable promiscuous mode.
First of, you need to create a bridge. This turns your Ubuntu Server into a switch so that your containers can access the LAN and pull IPs.
So this is what we need to install for that
Code:
sudo apt-get install bridge-utils
Next we need to configure the networking settings.
Code:
sudo nano /etc/network/interfaces
Remove eth0 (or comment out) from your file
Code:
# auto eth0
# iface eth0 inet dhcp
Add a bridge, and include your network interface in the bridge
Code:
auto br0
iface br0 inet dhcp
bridge_ports eth0
Save and reboot
Once rebooted `ip addr show` should now show br0 pulling and IP, and eth0 should be listed but no longer pulling an IP
By default, LXD uses a bridge that isn't connected to your LAN. So we're going to swap that bridge for your new bridge.
Code:
lxc profile edit default
Change parent: lxdbr0 to
Code:
parent: br0
And save
Now create your container. This downloads the container image and sets it up. The image is saved for creating more containers in the future
Code:
lxc launch ubuntu:16.04 nameofyourchoosing
To view your list of containers and see if they're pulling an IP
Code:
lxc list
To enter bash on your container
Code:
lxc exec nameofyourchoosing bash
See more LXD commands for working with your containers here
https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container-312/