What is the relationship between LXD and LXC?

Understanding the relationship between LXC (the low-level library) and LXD (the manager), and why we typically use LXD to manage containers.

Key Takeaway: LXD is the "Supercharged Version" of LXC

In simple terms, their relationship is:

  • LXC is the foundation: It is the low-level toolset and library that interacts directly with the Linux kernel to actually create and manage containers.
  • LXD is the manager: It is a daemon that builds on top of LXC, providing a modern, feature-rich REST API to manage LXC containers, and adding advanced features like networking, storage management, and clustering.

LXD uses LXC, but users typically only interact with LXD.

A Car Analogy

To better understand, we can compare them to a car:

  • LXC is like the car's engine, transmission, and chassis. It's the core power and drivetrain system; without it, the car can't move. But for the average driver, operating these components directly is complex and difficult.
  • LXD is like the entire car, complete with a steering wheel, dashboard, and comfortable seats. It encapsulates the complex underlying machinery (LXC) and provides the user with a simple, intuitive control interface (the `lxc` command-line tool and REST API) to drive with ease.
User Interaction Layer > lxc ... CLI Tool {...} REST API Client LXD (Daemon / Manager) 🌐 REST API đŸ—„ī¸ Image Mgmt 💾 Storage Mgmt 🔗 Network Mgmt 🤝 Clustering ⚡ Live Migration LXC (Low-level Library & Tools) liblxc.so lxc-create lxc-start lxc-attach Linux Kernel Namespaces Cgroups Seccomp AppArmor Capabilities

Why Do We Use LXD?

While you can use LXC commands directly (like `lxc-create`, `lxc-start`) to manage containers, this is generally only recommended for developers who want to delve into the low-level principles of containers. For the vast majority of daily use and production environments, LXD offers overwhelming advantages:

  • Powerful CLI Experience: LXD provides a unified and intuitive `lxc` command-line tool, which is much easier to use than LXC's scattered set of tools.
  • REST API: At its core, LXD is a REST API, which makes automation, integration, and building management tools extremely easy.
  • Advanced Networking & Storage: LXD has built-in management for networking (bridges, VLANs, etc.) and storage (ZFS, Btrfs, LVM, etc.), eliminating the need to manually configure complex files.
  • Clustering Capabilities: You can easily group multiple LXD hosts into a cluster and seamlessly migrate and manage containers between them. This is something LXC cannot do.
  • Image Management: LXD has a powerful remote image system, making it easy to fetch and update container images from official or community sources.
  • Live Migration: It supports live migration of running containers (using CRIU) between nodes in a cluster.

Conclusion: The Future-Proof Choice

LXC is the pioneer and cornerstone of Linux container technology, while LXD is the modern, full-featured management platform built upon that cornerstone. Together, they form a powerful and flexible system container solution.

For new users and production deployments, the choice is clear: you should use LXD. It provides a better experience, more powerful features, and a broader ecosystem.