How to understand the difference between LXD and VM and Docker?

Viewed 690

When I am using Travis-CI, I need to choose between LXD and full VM: https://docs.travis-ci.com/user/reference/overview/. Although the linked page describes their features in specific usages, I would like to ask how conceptually LXD differs from so-called full VM, and how do they compare with Docker? I would assume that a CI test should run on a server with Linux or other OS pre-installed and that we do not need to run a LXD or VM on the server side. So I am quite confused with the basic concepts of LXD or VM run on a server. Any clarification?

1 Answers

With a VM you can setup a full Linux distribution, and it runs a new Linux kernel and the distro's runtime. You need hardware support in the CPU for a VM, you need lots of memory, and it takes some time to boot up.

Through LXD, you can setup both VMs and system containers.

A system container behaves like a VM but does not use hardware virtualization. It uses Linux kernel features to isolate from the rest of your host, namely cgroups and namespaces.

In addition, a system container does not boot a separate Linux kernel; it reuses the Linux kernel of the host. Thanks to the Linux kernel stable API, your host may run Ubuntu and you can have system containers running Ubuntu, Fedora, Alpine, Oracle Linux, etc, all at the same time.

Comparatively, a system container takes up only a few resources compared to a VM. A typical Linux distribution as a system container may start off with about 200MB RAM.

System containers (and LXD VMs) use a storage pool, with either ZFS, btrfs, LVM or a few others. By doing so, they support copy-on-write, which means that the container creation is near instantaneous. Because there is already a container image ready in the storage pool, and any new containers are based on that container image. On fast servers it can be well under one second.

Related