LXC Containers, Azuracast and Yunohost, How It Worked?

I already have a yunohost server at home and wanted to install an azuracast server on the same machine. I tried it in a VM (virtualbox ), but didn’t work well since both needed the same ports. I also tried with 2 VMs, it’s ok but that required a host machine with a lot of RAM, and every VM will be allocated an amount of RAM even if it is not using it all. A waste of ressources and I didn’t really want to upgrade my hardware.

So I came across this cool youtube tutorial explaining how to share the same hardware ressources with different OSes. That’s when I decided to experiment LXC containers.

How I did :

  • Install ubuntu 18.04 server (recommended for running lxc containers) in your host machine (be sure to install ssh)

  • Login ssh to the server (using putty or konsole ) :

sudo su
apt update
apt upgrade
  • Update lxd to version 4 since the installed one is 3 and doesn’t support the routed nictype :
systemctl stop lxd
systemctl stop lxd.service
systemctl stop lxd.socket
apt purge lxd
apt autoremove
hash -r
reboot
  • Login again after reboot :
snap info lxd
snap install lxd –channel=4.0/stable
snap list
hash -r
lxd version
  • Initiate lxd :
lxd init

Default values are Ok.

  • Every container should have its own profile to have its own IP address.

  • Create a profile for the first container :

lxc profile create yunoprofile
  • Edit the profile yunoprofile :
lxc profile edit yunoprofile
  • Insert this code and adapt the settings to your needs (bold)
config:
 user.network-config: |
  #cloud-config
  version: 2
  ethernets:
    eth0:
      dhcp4: false
      dhcp6: false
      routes:
      – to: 0.0.0.0/0
      via: 169.254.0.1
      on-link: true  
 user.user-data: |
  #cloud-config
  bootcmd:
    – echo ‘nameserver 8.8.8.8’ > /etc/resolvconf/resolv.conf.d/tail
    – systemctl restart resolvconf  
description: Default LXD profile
devices:
  eth0:
    ipv4.address: **192.168.1.200**
    name: eth0
    nictype: routed
    parent: **enp0s3**
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: yunoprofile
used_by:
  • Create a debian 10×64 container (yunohost supports debian 10 at the moment of writing of this tutorial) :
lxc launch images:debian/10/amd64 yuno
  • Create a debian 11×64 container (for azuracast ) :
lxc launch images:debian/11/amd64 azura
  • Stop the container yuno :
lxc stop yuno
  • Assign the profile yunoprofile to the yuno container :
lxc profile assign yuno yunoprofile
  • Start the container :
lxc start yuno
  • “Login” to the container :
lxc exec yuno bash
  • Update the container :
apt-get update
  • Install curl :
apt install curl
  • Install yunohost :
curl https://install.yunohost.org | bash
  • Exit the container :
exit

Now yunohost is installed, go to 192.168.1.200 to continue the installation. That’s great, yunohost is running.

  • Make a copy a the yunoprofile to an azuraprofile :
lxc profile copy yunoprofile azuraprofile
  • Edit the azuraprofile and change this line :
ipv4.address: **192.168.1.200**
  • and set an another ip address :
ipv4.address: **192.168.1.201**
  • Stop the container azura :
lxc stop azura
  • Assign the azuraprofile to the azura container :
lxc profile assign azura azuraprofile
  • Start the azura container :
lxc start azura
  • Some others commands need to be run before proceeding :

  • For docker (needed before installing azuracast) :

lxc config set azura security.nesting true
  • For privileged LXC container (needed before installing azuracast) :
lxc config set azura security.privileged true
  • “Login” to the container :
lxc exec azura bash
  • Update the container :
apt-get update
  • Install curl :
apt install curl
  • Install azuracast :
mkdir -p /var/azuracast
cd /var/azuracast
curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/docker.sh > docker.sh
chmod a+x docker.sh
./docker.sh install

Now azuracast installed, go to 192.168.1.201 to continue installation. Now azuracast is running.

That’s it, now we have both yunohost and azuracast in the same machine with different IP addresses.

Go to yunohost and add a domain (or subdomain) for azuracast, run diagnosis, install ssl certificate, install app “redirect app” and set “nginx_proxy_pass” and use the domain added for azuracast as the redirect url.


I tried this in a virtual machine (virtualbox) with 2G ram / 20G hdd. The host machine is a windows 7 with a core2duo 2Ghz/4M, 4G ram.

Ressource usage is not really heavy, the azuracast server is running and still no apps installed in yunohost (apart from netdata) :

free -h & df -h

I read that it is not recommended to install azuracast in a lxc container and that setting “security.privileged true” is not a good idea, without saying why.

I’ll continue to test this installation and when possible will test it in a real machine.

Copyright

Comments