This is cool - running snaps in LXD unprivileged containers

Maybe this is only news to me but I just learned that you can easily run SNAPs in LXD unprivileged containers.

I wanted to run NextCloud in an LXD container. Thought I’d try it with the NextCloud SNAP since its current version.

$ lxc launch ubuntu: nextcloud

$ lxc exec nextcloud bash

now while logged into the nextcloud container as root update/upgrade

root@nextcloud:~# apt update && apt upgrade -y

important: install squashfuse

root@nextcloud:~# apt install squashfuse

install SNAP

root@nextcloud:~# apt install snap

finally install the NextCloud Snap

root@nextcloud:~# snap install nextcloud

when that’s done start your Host’s browser and point it to the IP address of the nextcloud container

The 1st login to NextCloud creates the Admin Account.

After that you are all set.

Anyway I thought this was cool :slight_smile:

It opens up the possibility of running many/most of the currently available SNAPs in LXD containers really easily:

https://uappexplorer.com/snaps

4 Likes

What is missing, is people writing about this. Therefore, it was great you posted it.

The package should be squashfuse instead. At least, that’s the name for the Ubuntu 16.04 cloud image.
Ideally, this package should be preinstalled in the Ubuntu cloud image.

Another difference between snaps on host and snaps on an LXD unprivileged container, is that now you need to sudo snap install (that is, add sudo when you do not need sudo on the host).

1 Like

on ubuntu 18.04 container: install squashfuse with fuse “sudo apt install squashfuse fuse”, install snapd instead of snap “apt install snapd”. everything else fine.

1 Like

Thank you for this! - I have one question though - I now have this working but I can only access the NextCoud instance on the laptop I installed it on - How do I get at it from (for example) the phone app (even if it’s just on the same WiFi as the host)? What settings do I need to put in? Do I need to do something on my wifi router? - Thanks again for the post, it’s exactly what I was looking for.

Hi Richard!

To expose the nextcloud instance to the LAN, there are a few options.
In your case with WLAN (WiFi LAN), you can use a LXD proxy device to expose the port 80 of the next cloud instance to port 80 of the host. Let’s assume at the container is called “mynextcloud”.
Then, run on the host

lxc config device add mynextcloud port80 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80

This command will listen for connections on the host at port 80, and then proxy them to the container mynextcloud to port 80.

Thank you!! I’ll give this a try. Do I need to set listen=tcp:0.0.0.0:80 to my NextCloud container IP or do I just copy the whole thing replacing the container name only?

Only container name needs changing, 0.0.0.0:80 will cause all addresses on your host to be listened on, 127.0.0.1:80 is the target address in the container on which nextcloud should already be listening.

Sorry for the late reply. Thank you so much for all your help - it’s all up and running :slight_smile: