Getting started with LXD Containerization

Originally published at: Getting started with LXD Containerization – LearnLinuxTV

LXD is a next generation container manager that provides additional features that are similar to virtual machines, such as snapshots, storage pools, and more. Using Linux containers (LXC) as the container type, LXD gives you the best of two worlds. In this video, I’ll go over the basics of LXD. You’ll learn how to set…

3 Likes

@jay, this one was AWESOME! I’ve been a Linux desktop user for a while on my home and spare machines, but have done very little on the server side. Containers, Docker, and Podman are still a tech that I’m struggling to wrap my head around. I loved your Docker series, that was excellent. I think that LXD clicks better with my brain. Also when I realized from this video how easy it was to add snaps to Debian, I decided to upgrade my Debian 10 box to Debian 11 and add snapd to experiment with LXD. I would be in favor of more LXD content. I doubt that I would get into clustering with LXD because I have mostly old boxes that I use in my homelab that people have gotten rid of because they are too slow for Windows, but I’m interested to see how I can use containers on these older boxes to do homelab things. Thanks Jay for making this one.

I think LXD might be under-rated. LXD leans into what docker isn’t.

Whenever anyone learns docker, they inevitably end up using it like a VM (at least at first). But docker is designed for apps* not complete systems (*server-side apps). A docker image is supposed to be like an app on the app store. It’s all very confusing because it really looks like a VM alternative. A big reason for this, is because Docker uses sys-admin tools to setup the file system. To be fair, tools like apt are the best tools for the job, but that subverts expectations.

LXD tries to be a VM alternative. It’s what docker isn’t! And sometimes that’s exactly what you need.

My near term goal is to run Umbrel on LXD. It seems like a cool project, but Pi4s are too expensive right now. So I’m gonna use a cheap NUC instead. (I got an Atlas Canyon N6005 for $180 on CDW). I’m super excited for this project. Right now I want to run 2 containers. One to run umbrell and one to be a NAS.

1 Like

Welcome to the forum!

I agree with you on LXD being underrated and LXC being a (Linux) VM alternative (somewhat). But docker / k8s is not really an app store. Sure, you can get whatever stuff you want from the docker hub, but that’s not the point. You can create your own containers from a base image and only add whatever you need.

Docker focuses more on the programs themselves, LXD focuses on the system as a whole. LXD is an orchestrator to more easily manage LXC. LXC aims to be somewhat like what VMs are today, but lighter and more efficient. LXD aims to be something like a more integrated solution for managing LXC, kind of like OpenStack is, but with way less things that it does (and LXD is available for OpenStack). With LXC, you won’t get the benefit of running your own kernel, but you may also have other advantages that come with LXD because of that. So if you program doesn’t have a specific need for a kernel or kernel module, LXC should work great. Easiest things to set up in LXC are web servers and databases

Managing LXD is just like managing any other VM infrastructure. You automate stuff to update your systems, or in many cases, that automation is already in place, just use whatever OS you need for the container. Backing up data from LXC is also easier IMO.

On Docker, you still get an OS base image, but managing it is a completely different beast. All containers are supposed to be ephemeral. You use docker-compose or whatever other tools to create a container, spin it up and have it run whatever you want. If you want persistent storage, you either point the containers to a network share or a DB or something similar, outside of them, or you create a persistent volume for the OCI container and you point other ephemeral ones to those.

OCI containers are supposed to be administered via whatever orchestrator you have (k8s, k3s, microk8s, k0s, docker, docker swarm, podman etc.). The programs inside never get updated, you just create a new container with an updated program and delete the old one. This does technically give admins a lot of flexibility, but it makes for a more complicated setup process, unlike just spinning up a new OS.

In addition, whatever you put on an OCI container will run and behave the same anywhere. Technically you can just tar a LXC file system and send it to people, but it’s a bit clunkier than how OCI containers do versioning. But those technologies don’t really compete with each other. And you can even run OCI containers inside LXC.

With that said, I find myself using LXD and not using OCI containers unless strictly necessary.