LXC and LXD: Explaining Linux Containers | Sumo Logic (2024)

LXC and LXD are two important acronyms to know if you’re into containers. Unfortunately, they’re also acronyms that are hard to keep straight from one another. They sound alike. They refer to similar platforms, which were created in large part by the same company. And they’re deeply intertwined with one another at a technical level.

If this sounds confusing, it’s because it is, at least at first. Fortunately, with a little bit of explaining, it’s easy enough to understand LXC, LXD and what they mean for admins and developers who want to use containers.

This post explains what LXC and LXD are, what’s different between them, and why developers or admins would want to use them—or, alternatively, why they might prefer to stick with Docker or CoreO.

Complete Visibility for DevSecOps

See how Sumo Logic breaks down data silos and provides visibility and insights to your Development, Security, and Operations teams.

LXC

To understand LXD you first have to understand LXC.

LXC—short for “Linux containers”, is a solution for virtualizing software at the operating system level within the Linux kernel. Unlike traditional hypervisors (think VMware, KVM and Hyper-V), LXC lets you run single applications in virtual environments, although you can also virtualize an entire operating system inside an LXC container, if you’d like.

LXC’s main advantages include making it easy to control a virtual environment using userspace tools from the host OS, requiring less overhead than a traditional hypervisor and increasing the portability of individual apps by making it possible to distribute them inside containers.

If you’re thinking that LXC sounds a lot like Docker or CoreOS containers, it’s because LXC used to be the underlying technology that made Docker and CoreOS tick. More recently, however, Docker has gone in its own direction and no longer depends on LXC. CoreOS now also does its own thing with Rocket (also known as rkt, for people who really dislike typing). Still, LXC was at the origin of the container revolution several years ago, and LXC principles—if not LXC code — remain central to the way containers are developing.

LXD

The simplest way to define LXD is to say it’s an extension of LXC. LXD also happens to be LXC’s main claim to fame, now that LXC has ceased to be important for Docker and CoreOS.

The more technical way to define LXD is to describe it as a REST API that connects to libxlc, the LXC software library. LXD, which is written in Go, creates a system daemon that apps can access locally using a Unix socket, or over the network via HTTPS.

LXD’s main selling points include the following:

  • A host can run many LXC containers using only a single system daemon, which simplifies management and reduces overhead. With pure-play LXC, you’d need separate processes for each container.
  • The LXD daemon can take advantage of host-level security features to make containers more secure. On plain LXC, container security is more problematic.
  • Because the LXD daemon handles networking and data storage, and users can control these things from the LXD CLI interface, it simplifies the process of sharing these resources with containers.
  • LXD offers advanced features not available from LXC, including live container migration and the ability to snapshot a running container.

Canonical, the company that funds the Ubuntu GNU/Linux operating system (and which, not coincidentally, is also a major supporter of LXC), launched LXD in late 2014. If I were writing this post just a few months ago, I would say that LXD is not yet ready for real-world use.

LXC and LXD: Explaining Linux Containers | Sumo Logic (1)

Why the Sumo Logic App for Linux?
Learn more.

But a lot has changed recently, and LXD 2.0, the first production release, is out as of April 2016. Now, LXD is finally ready for production-level use.

(What about LXD 1.0, you ask? There was no LXD 1.0. The developers skipped straight to LXD 2.0 because it was released in parallel with LXC 2.0.)

LXC and LXD

If you’re an app developer or data center admin, you’re probably wondering what all of the above means for you, and which container solution you should choose.

The answer is complicated. First of all, understand that you can’t choose between LXC and LXD, because they’re not distinct things. They’re not forks or clones of one another. LXD depends on LXC. They’re both being developed in tandem, by the same general group of programmers. So if you use LXD, you’re using LXC, too, and you always will.

Yes, you could use LXC without LXD. But you probably would not want to. On its own, LXC will give you only a basic subset of features. For a production environment, you’ll want to use LXD.

LXC+LXD vs. Docker/CoreOS

LXC and LXD: Explaining Linux Containers | Sumo Logic (2)

You’re probably also wondering whether the LXC+LXD combo is better than Docker or CoreOS. The answer depends on your needs.

First, note that Canonical does not intend LXC+LXD to be a replacement for Docker. Instead, as Stéphane Graber, one of the LXD developers writes, LXD is designed for hosting virtual environments that “will typically be long running and based on a clean distribution image,” whereas “Docker focuses on ephemeral, stateless, minimal containers that won’t typically get upgraded or re-configured but instead just be replaced entirely.”

This means you should consider the type of deployment you will have to manage before making a choice regarding LXD or Docker (or CoreOS, which is similar to Docker in this regard). Are you going to be spinning up large numbers of containers quickly based on generic app images? If so, go with Docker or CoreOS. Alternatively, if you intend to virtualize an entire OS, or to run a persistent virtual app for a long period, LXD will likely prove a better solution.

The second factor to consider is your host environment. LXD only supports Linux—and, at least for now, it’s really only documented for use with Ubuntu. So if your servers run another flavor of Linux or Windows, LXD won’t work well for you. In contrast, Docker and CoreOS are pretty portable across almost any Linux-based OS, and you can now even run Docker natively on Windows and OS X.

Your mileage may vary, of course. But these are the basics. Now, happy containering!

Editor’s Note: LXC and LXD: Explaining Linux Containers is published by the Sumo Logic DevOps Community. If you’d like to learn more or contribute, visit devops.sumologic.com. Also, be sure to check out the Sumo Logic Open Source page for free tools and code that will enable you to monitor and troubleshoot applications from code to production.

Additional Resources

Complete Visibility for DevSecOps

See how Sumo Logic breaks down data silos and provides visibility and insights to your Development, Security, and Operations teams.

LXC and LXD: Explaining Linux Containers | Sumo Logic (2024)

FAQs

What is LXC and LXD containers? ›

LXD is an open source container management extension for Linux Containers (LXC). LXD both improves upon existing LXC features and provides new features and functionality to build and manage Linux containers.

Is LXC obsolete? ›

The LXC project is still going strong and shows no signs of winding down; LXC 5.0 was released in July and comes with a promise of support until 2027.

What is the use of LXD? ›

LXD provides a unified user experience for managing system containers and virtual machines. For more demanding workloads, LXD can be set up in a cluster environment to run containers, VMs, or a combination of the two on a set of machines.

Is LXD better than Docker? ›

Speed of Operation: Docker is faster than LXD in terms of CPU performance only when a single processor is used. On the contrary, LXD is faster than Docker in executing applications using multiple processors.

How does LXC work? ›

LXC provides operating system-level virtualization through a virtual environment that has its own process and network space, instead of creating a full-fledged virtual machine. LXC relies on the Linux kernel cgroups functionality that was released in version 2.6.

Where are LXD images stored? ›

dir driver in LXD

Unless specified differently during creation (with the source configuration option), the data is stored in the /var/snap/lxd/common/lxd/storage-pools/ (for snap installations) or /var/lib/lxd/storage-pools/ directory.

Does Docker still use LXC? ›

Docker is developed in the Go language and utilizes LXC, cgroups, and the Linux kernel itself. Since it's based on LXC, a Docker container does not include a separate operating system; instead it relies on the operating system's own functionality as provided by the underlying infrastructure.

Is LXC faster than VM? ›

LXC's start much faster than VMs and use fewer host resources per container than VMs, so they are ideal for combinations of packing a lot of isolated processes onto one host and/or starting them up frequently.

When to use LXC instead of Docker? ›

LXC provides us full system virtualization. Docker provides application virtualization. There is no need for cloud storage as Linux provides each feature. The need of cloud storage is required for a sizeable ecosystem.

What is the difference between LXC and LXD? ›

LXC is the technology allowing the segmentation of your system into independent containers, whereas LXD is a daemon running on top of it allowing you to manage and operate these instances in an easy and unified way.

What does LXC stand for? ›

Linux Containers (LXC) is a type of virtualization setup that works with virtual containers created at the operating system level.

What does Linux LXD stand for? ›

LXD stands for Linux Container Daemon. Yet another container technology.

Can Kubernetes run LXC containers? ›

A step-by-step guide to get kubernetes running inside an LXC container. This guide is an alternative to minikube which also offers a local kubernetes environment. The advantage of the LXC approach is that everything runs natively on the host kernel without any virtualization costs from a Virtual Machine.

What is the best container runtime? ›

Runc is still the most reliable choice if there is no special requirement, but runv wins sometimes. See the two specific scenarios below, for instance. A multi-tenant environment requires higher isolation. Financial systems have relatively high-security requirements.

Is LXC faster than Docker? ›

The performance difference between LXC and Docker is almost insignificant. Both provide fast boot times. Downloading an LXC image might be slower than distroless Docker images, but not all Docker images are distroless, giving Docker room for improvement as compared to LXC.

What does LXC focus on? ›

LXC's main focus is system containers. That is, containers which offer an environment as close as possible as the one you'd get from a VM but without the overhead that comes with running a separate kernel and simulating all the hardware.

How do Linux containers work? ›

Linux containers, in short, contain applications in a way that keep them isolated from the host system that they run on. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

Do LXC containers have their own kernel? ›

LXC containers are often considered as something in the middle between a chroot and a full-fledged virtual machine. The goal of LXC is to create an environment as close as possible to a standard Linux installation but without the need for a separate kernel.

Does LXD use KVM? ›

Since the LXD driver is able to deploy KVM images and KVM VM templates, make sure you specify on the templates where do you want the VM/container.

How do I create a lxc template? ›

Creating template on Ubuntu
  1. Install lxc: apt-get install lxc.
  2. Create a container with any name, in our case 'ubuntu': ...
  3. Creation of the LXC container will take a lot of time, it will be stored here: /var/lib/lxc/ubuntu.
  4. Next stop the container: ...
  5. Next create a temp director, tar the rootfs and export the template:
Jun 19, 2014

Where is LXD config stored? ›

The configuration file which was used may be found under /var/log/lxd/c1/lxc. conf while apparmor profiles can be found in /var/lib/lxd/security/apparmor/profiles/c1 and seccomp profiles in /var/lib/lxd/security/seccomp/c1 .

Why Docker is shutting down? ›

The process inside the container has been terminated: This is when the program that runs inside the container is given a signal to shut down. This happens if you run a foreground container (using docker run ), and then press Ctrl+C when the program is running.

Is LXC a hypervisor? ›

LXC (also known as Linux containers) is a virtualization technology that works at the operating system level. This is different from hardware virtualization, the approach used by other hypervisors such as KVM, Xen, and VMware.

Is Kubernetes getting rid of Docker? ›

A while ago, Kubernetes announced that it was deprecating Docker. Actually, it was deprecating something called dockershim, and Docker alongside it. Roughly one year after the announcement, Docker was completely removed from Kubernetes. Now, Kubernetes is a container orchestrator.

Can you ssh into a LXC container? ›

By default it's not possible to establish a direct SSH connection to a Proxmox LXC container. In order to SSH into a container there are two options available. Either you attach to the container through Proxmox host or you allow login with password on the specific container.

Are LXC containers secure? ›

The two types of LXC containers are privileged containers and unprivileged containers. Privileged containers are insecure and require kernel features for security. On the other hand, unprivileged containers are safer and use kernel features for an extra layer of security.

Is LXC a container runtime? ›

LXC is a well-known Linux container runtime that consists of tools, templates, and library and language bindings.

Where are LXC containers stored? ›

By default, containers are located under /var/lib/lxc for the root user.

What is TurnKey LXC? ›

TurnKey LXC simplifies downloading and deploying multiple TurnKey apps side-by-side on the same host in securely isolated lightweight containers while handling tricky details such as network routing.

Why is Linux better for containers? ›

Compared to virtual machines, a running Linux container is less resource-intensive, has a standard interface (start, stop, environment variables, etc.), retains application isolation, and is more easily managed as part of a larger application (multiple containers).

Who uses LXD? ›

Who uses LXD? 8 companies reportedly use LXD in their tech stacks, including Dek-D, Demonware, and Passbase.

How do I list all LXC containers? ›

lxc-ls --fancy list all the containers, listing one per line along with its name, state, ipv4 and ipv6 addresses. lxc-ls --active -1 list active containers and display the list in one column.

Is LXC open source? ›

LXC is free software, most of the code is released under the terms of the GNU LGPLv2. 1+ license, some Android compatibility bits are released under a standard 2-clause BSD license and some binaries and templates are released under the GNU GPLv2 license.

How do I run a Windows virtual machine on Linux LXD? ›

How to run a Windows virtual machine on LXD on Linux
  1. Download a Windows 10 ISO from Microsoft.
  2. Prepare the ISO using distrobuilder (we do this once per ISO).
  3. Start the virtual machine from that prepared ISO and go through the installation.
Feb 27, 2021

What is canonical LXD? ›

Canonical LXD is a next generation system container manager.It offers a user experience similar to virtual machines but using Linux containers instead.

Where are lxc snapshots stored? ›

Snapshots are stored as snapshotted containers under the container's configuration path. For instance, if the container's configuration path is /var/lib/lxc and the container is c1, then the first snapshot will be stored as container snap0 under the path /var/lib/lxc/c1/snaps.

What should you not Containerize? ›

So, one example of when not to use containers is if a high level of security is critical. They can require more work upfront: If you're using containers right, you will have decomposed your application into its various constituent services, which, while beneficial, isn't necessary if you are using VMs.

Which is faster VM or container? ›

Docker containers are generally faster and less resource-intensive than virtual machines, but full VMware virtualization still has its unique core benefits—namely, security and isolation.

How many processes run in a container? ›

Container-based application design encourages certain principles. One of these principles is that there should just be one process running in a container. That is to say, a Docker container should have just one program running inside it. Docker is efficient at creating and starting containers.

Does LXC use chroot? ›

LXC is a similar idea to the earlier Vserver (or containers in BSD and Solaris). LXC uses a single kernel shared among virtual machines, processes separated by cgroups, filesystems separated using chroot.

Is LXC same as Docker? ›

Unlike LXC, which launches an operating system init for each container, Docker provides one OS environment, supplied by the Docker Engine, and enables developers to easily run applications that reside in their own application environment which is specified by a docker image.

Should I use Docker or LXC? ›

LXC is less scalable compared to Docker. Its images are not as lightweight as those of Docker. However, LXC images are more lightweight than those of physical machines or virtual machines. That makes it ideal for on-demand provisioning and autoscaling.

Why LXC is better than Docker? ›

LXC provides us full system virtualization. Docker provides application virtualization. There is no need for cloud storage as Linux provides each feature. The need of cloud storage is required for a sizeable ecosystem.

Can LXC run Docker images? ›

By running docker inside LXC, you get all the gains of running docker in its own isolated environment away from the host, but without the complexities and overhead that would come with running docker in a full VM.

Top Articles
Latest Posts
Article information

Author: Otha Schamberger

Last Updated:

Views: 5614

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Otha Schamberger

Birthday: 1999-08-15

Address: Suite 490 606 Hammes Ferry, Carterhaven, IL 62290

Phone: +8557035444877

Job: Forward IT Agent

Hobby: Fishing, Flying, Jewelry making, Digital arts, Sand art, Parkour, tabletop games

Introduction: My name is Otha Schamberger, I am a vast, good, healthy, cheerful, energetic, gorgeous, magnificent person who loves writing and wants to share my knowledge and understanding with you.