用途:面向 LXC/LXD 系统容器的日常管理,涵盖容器创建、启停、资源限制、配置文件、快照、网络、存储池与文件传输。
主要能力:区分三层工具——LXC 为底层容器工具(lxc-* 命令),LXD 为基于 LXC 的高层守护进程并提供 REST API(CLI 名为 lxc),Incus 为 LXD 的社区分支(API 兼容,命令为 incus)。支持 lxc launch、lxc exec、lxc list、lxc config set、lxc profile、lxc network、lxc storage、lxc snapshot、lxc file push/pull、lxc export/import 等操作。
使用方式:安装可用 snap install lxd、apt install lxd 或 apt install incus;首次运行 lxd init 初始化。常用示例:lxc launch ubuntu:24.04 mycontainer;lxc exec mycontainer -- bash;lxc config set mycontainer limits.cpu 2;lxc config set mycontainer limits.memory 512MB;lxc snapshot mycontainer snap0。非 root 用户需加入 lxd(或 incus)组。
适用场景:需要轻量系统级隔离、批量管理容器、做资源配额与快照回滚、在容器内运行 Docker 等场景。
限制与注意:snap 版 LXD 路径位于 /var/snap/lxd/,与 deb 版 /var/lib/lxd/ 不同;配置文件存于守护进程数据库,无扁平配置文件;profile 继承为叠加而非覆盖;非特权容器存在 UID/GID 映射问题;limits.cpu 与 limits.memory 需 cgroups v2;特权容器有安全风险。2023 年后非 Ubuntu 系统建议优先选用 Incus。具体版本与平台支持暂未提供。