This tutorial was done with the Armbian Bionic image.
The Pi will need an SD card installed with an Armbian bionic image (there are lots of tutorials of this online) and to be connected to the network and you will need to be SSH’d to the device. to do this connect it to your home router via Ethernet and use an app like fing or a tool like NMAP to find the device IP.
You can then SSH to the device as follows:
ssh root@<pi IP> Password: 1234
You will then be asked to create a new user, follow the onscreen instructions.
Once you are SSH’d to the pi and the user account creation is complete run the following command
apt update && apt upgrade
This will make sure that your packages are up to date and that you are ready to continue with the installation.
You can then install LXC and the necessary packages as follows:
apt-get install lxc lxc-templates wget bridge-utils debootstrap
Once this has completed you need to configure networking. The easiest route is to create a linux bridge.
edit the following file: /etc/network/interfaces and replace the config with the configuration below with the address, netmask, broadcast and gateway for your network. If you’re unsure of your network settings type ip addr show
The config should look something like this:
auto lo iface lo inet loopback auto eth0 iface eth0 inet manual ##Bridge Name ### auto br0 ### Bridge Information iface br0 inet static bridge_ports eth0 bridge_stp off bridge_fd 9 ### Bridge IP ### address 10.0.69.2 netmask 255.255.255.0 network 10.0.69.0 broadcast 10.0.69.255 gateway 10.0.69.1 dns-nameservers 188.8.131.52
Once this is complete you will need to reboot the PI and SSH back to the device. You should now see the following if you run ip addr show
br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether fa:7b:80:81:65:cf brd ff:ff:ff:ff:ff:ff inet 10.0.69.12/24 brd 10.0.69.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::f87b:80ff:fe81:65cf/64 scope link
Now that networking is configured you need to tell LXC to use the bridge device.
Edit /etc/lxc/default.conf and add the following config:
USE_LXC_BRIDGE="false" lxc.net.0.type = veth lxc.net.0.link = br0 lxc.net.0.flags = up lxc.net.0.hwaddr = 00:16:3f:xx:xx:xx
You can now run systemctl restart lxc-net.service.
LXC is now fully configured and you can create your first container, I chose Debian for the container OS and created my first container as follows:
lxc-create -n test -t debian
This will create a container with a base install of debian, start the container by running
lxc-start -n test lxc-attach -n test
You can now configure your container as you like! I’d recommend starting with an apt update.
This concludes how to install and configure LXC to work on a NanoPI fire 3 or any other Ubuntu/Debian based device.
Let me know below if you have any feedback!