简体   繁体   English

如何理解LXD和VM和Docker的区别?

[英]How to understand the difference between LXD and VM and Docker?

When I am using Travis-CI, I need to choose between LXD and full VM: https://docs.travis-ci.com/user/reference/overview/ .当我使用 Travis-CI 时,我需要在 LXD 和完整 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?虽然链接页面描述了它们在特定用法中的功能,但我想问一下 LXD 在概念上与所谓的完整 VM 有何不同,它们与 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.我假设 CI 测试应该在预装了 Linux 或其他操作系统的服务器上运行,并且我们不需要在服务器端运行 LXD 或 VM。 So I am quite confused with the basic concepts of LXD or VM run on a server.所以我对在服务器上运行的 LXD 或 VM 的基本概念感到非常困惑。 Any clarification?任何澄清?

With a VM you can setup a full Linux distribution, and it runs a new Linux kernel and the distro's runtime.使用 VM,您可以设置完整的 Linux 发行版,它运行新的 Linux kernel 和发行版的运行时。 You need hardware support in the CPU for a VM, you need lots of memory, and it takes some time to boot up.您需要在 CPU 中为 VM 提供硬件支持,您需要大量的 memory,并且启动需要一些时间。

Through LXD, you can setup both VMs and system containers .通过 LXD,您可以设置虚拟机和系统容器

A system container behaves like a VM but does not use hardware virtualization.系统容器的行为类似于 VM,但不使用硬件虚拟化。 It uses Linux kernel features to isolate from the rest of your host, namely cgroups and namespaces .它使用 Linux kernel 功能与您的主机的 rest 隔离,即cgroupsnamespaces

In addition, a system container does not boot a separate Linux kernel;另外,系统容器不引导单独的 Linux kernel; it reuses the Linux kernel of the host.它重用了主机的 Linux kernel。 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. 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.相比之下,与 VM 相比,系统容器只占用很少的资源。 A typical Linux distribution as a system container may start off with about 200MB RAM.作为系统容器的典型 Linux 分发可能从大约 200MB RAM 开始。

System containers (and LXD VMs) use a storage pool, with either ZFS, btrfs, LVM or a few others.系统容器(和 LXD VM)使用存储池,包括 ZFS、btrfs、LVM 或其他一些。 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.在快速服务器上,它可能不到一秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM