User Tools

Site Tools


How to have Alpine Linux in LXC container working and running

For LXC containers we're using images from LinuxContainers.org, but they or somebody else decided to remove images for armhf architecture, which we use in Turris Omnia a few days ago.
Now we're using minimal root filesystem directly from Alpine developers from their official website, but they're primarily made for chroot or Docker. I created issue on Github and hopefully they bring back Alpine images for armhf at LinuxContainers.org

First I will show you how to install Alpine in LXC containers and then we'll need to do some stuff like setup network manually and install busybox-initscripts and after reboot or each start of LXC containers to have networking connection.

This manual was tested by a community for Alpine version 3.6 a 3.7.

Usage for LXC containers

Install

Login to the SSH and install LXC containers how it is advised in official LXC article so it means that first, you need USB flash drive or hard drive, where do you install LXC container and then you need enter the folder, where you have it mounted and do this command:

lxc-create -t download -n nameofyourcontainer

Now you need to attach it with this command

lxc-attach -n nameofyourcontainer

Now you need to setup network manually by this

mount -t proc proc proc/
ifconfig eth0 x.x.x.x netmask y.y.y.y up
route add default gw z.z.z.z
echo "nameserver 8.8.8.8" > /etc/resolv.conf

Now you need to add initialization scripts

apk update
apk add busybox-initscripts

Create configuration file for network /etc/network/interfaces with content

auto eth0
iface eth0 inet dhcp
hostname $(hostname)

Set automatic startup for network

rc-update add networking
rc-update add bootmisc boot
rc-update add syslog boot

Now you need to reboot it and it's done. :-)