Skip to content

Many Snaps on LXC

Lauri Ojansivu edited this page Aug 17, 2020 · 6 revisions

1) Main Snap on bare metal

Install Wekan Snap to newest Ubuntu bare metal server. Snaps have automatic updates.

For example:

sudo apt-get install snapd
reboot
sudo snap install wekan

For Let's Encrypt SSL, like this to /var/snap/wekan/common/Caddyfile. We will be proxying to inside LXD container:

boards.example.com {
	tls {
	    alpn http/1.1
	}

	proxy / 10.10.10.231:3001 {
	  websocket
	  transparent
	}
}

For CloudFlare SSL, like this to /var/snap/wekan/common/Caddyfile:

http://boards.example.com https://boards.example.com {
	tls {
	    load /var/snap/wekan/common/certificates
	    alpn http/1.1
	}

	proxy / 10.10.10.231:3001 {
	  websocket
	  transparent
	}
}

2) New LXC container

So when I start new lxc container:

lxc launch images:ubuntu/20.04 lxccontainername

3) Snapd and Wekan

Then I go inside container and install snapd:

lxc exec lxccontainername -- /bin/bash
apt -y install snapd
reboot
lxc exec lxccontainername -- /bin/bash
snap install wekan
snap set wekan root-url='https://boards.example.com'
sudo snap set wekan port='3001'
sudo snap set wekan mail-from='Wekan Team Boards <info@example.com>'
sudo snap set wekan mail-url='smtps://username:password@email-smtp.eu-west-1.amazonaws.com:587'
ip address
exit

That ip address command does show current IP address of container, that you can then add to bare metal /var/snap/wekan/common/Caddyfile.

You can also add more lxc containers to different subdomains and proxy to them in main Caddyfile.

4) Some LXC commands

New Ubuntu container

lxc launch images:ubuntu/20.04 lxccontainername

Inside LXC container

lxc exec lxccontainername -- /bin/bash

Running command in LXC

lxc exec lxccontainername -- apt install p7zip-full

Limit RAM available to LXC

lxc config set lxccontainername limits.memory 4GB

New Debian container

lxc launch images:debian/buster mydebiancontainername

New CentOS 7 container

lxc launch images:centos/7/amd64 centos

List containers

lxc list -cns

Result:

+---------------+---------+
|     NAME      |  STATE  |
+---------------+---------+
| mycontainer   | RUNNING |
+---------------+---------+

Stop and delete container

lxc stop mycontainer
lxc delete mycontainer