Add misc tips to configure LXC properly

This commit is contained in:
Alexandre Aubin 2019-02-06 23:06:15 +01:00
parent db04eb9463
commit 0a989d0c56
3 changed files with 31 additions and 4 deletions

View file

@ -49,10 +49,29 @@ lxc-checkconfig
echo "veth" | sudo tee -a /etc/modules
```
On Debian Buster, I had to re-patch the driver.rb of vagrant-lxc plugin with [this version](https://raw.githubusercontent.com/fgrehm/vagrant-lxc/2a5510b34cc59cd3cb8f2dcedc3073852d841101/lib/vagrant-lxc/driver.rb) (especially the `roofs_path` function). I also had to install `apparmor` then `systemctl restart apparmor` for `lxc-start` to work.
On Debian Buster, I had to re-patch the driver.rb of vagrant-lxc plugin with [this version](https://raw.githubusercontent.com/fgrehm/vagrant-lxc/2a5510b34cc59cd3cb8f2dcedc3073852d841101/lib/vagrant-lxc/driver.rb) (especially the `roofs_path` function). I also had to install `apparmor` then `systemctl restart apparmor` for `lxc-start` to work. Also check instruction on https://feeding.cloud.geek.nz/posts/lxc-setup-on-debian-stretch/
If you run Archlinux, this page should be quite useful to setup LXC : https://github.com/fgrehm/vagrant-lxc/wiki/Usage-on-Arch-Linux-hosts
Typically `/etc/default/lxc-net` and `/etc/lxc/default.conf` should look like this :
```
> cat /etc/default/lxc-net
USE_LXC_BRIDGE="true"
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX="253"
> cat /etc/lxc/default.conf
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
```
Then, go into your favorite development folder and deploy ynh-dev with :
```bash

View file

@ -4,7 +4,7 @@
BOX="ynh-dev"
# Create box
vagrant up $BOX
vagrant up $BOX --provider=lxc
# Package box
vagrant package $BOX --output /tmp/$BOX.box

12
ynh-dev
View file

@ -113,6 +113,10 @@ function create_sym_link() {
function start_ynhdev()
{
[[ $(systemctl is-active lxc-net) == "active" ]] || critical "Service lxc-net should be running ... You probably need to fix your lxc network conf before being able to use lxc's."
ip a | grep lxcbr0 -q || critical "There is no 'lxcbr0' interface. You probably need to fix your lxc network conf before being able to use lxc's."
local NAME=${1:-ynh-dev}
local BOX_NAME="yunohost/$NAME"
local BOX_URL="https://build.yunohost.org/yunohost-$BOX_NAME-lxc.box"
@ -145,16 +149,20 @@ function destroy_ynhdev()
function rebuild_ynhdev()
{
[[ $(systemctl is-active lxc-net) == "active" ]] || critical "Service lxc-net should be running ... You probably need to fix your lxc network conf before being able to use lxc's."
ip a | grep lxcbr0 -q || critical "There is no 'lxcbr0' interface. You probably need to fix your lxc network conf before being able to use lxc's."
local BOX="ynh-dev"
set -x
cd prebuild
# Create box
vagrant up $BOX
vagrant up $BOX --provider=lxc || critical "Could not create the box ?"
# Package box
vagrant package $BOX --output /tmp/$BOX.box
vagrant package $BOX --output /tmp/$BOX.box || critical "Could not package package the box ?"
# Destroy current box
vagrant destroy $BOX