VM映像和Docker映像之间有什么区别? [英] What are the differences between a VM image and a Docker image?

查看:273
本文介绍了VM映像和Docker映像之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Docker和Virtual Machine的图像是否有差异?
除了图像格式,我无法找到任何信息。
请注意图像大小,实例创建时间,捕获时间等等。
谢谢!

解决方案

这些是我可以列出的码头和VM镜像之间的一些区别:



1。 Docker中的快照过程比VM更快



我们通常以基本图像开头,然后进行更改,并使用docker提交这些更改,创建一个图像。此图像仅包含与基数的差异。当我们想要运行我们的图像时,我们还需要基础,并且使用分层文件系统将图像分层在基础之上。文件系统将不同的层合并在一起,我们得到了我们想要的,我们只需要运行它。由于docker通常会建立在注册表中的现成图像之上,所以我们很少必须对整个操作系统进行快照。 Dockers将操作系统快照成通用图像的这种能力也使得在其他docker主机上部署更容易。



2。 Docker的启动时间比虚拟机少。



虚拟机通常需要几分钟才能启动,但容器需要几秒钟,有时甚至不到一秒。 / p>

4。 Docker图像具有更多的可移植性



Docker图像由图层组成。当我们拉或转移图像时,只检索我们尚未缓存的图层。这意味着如果我们使用基于相同基本操作系统的多个映像,则只创建或检索基础层一次。 VM图像没有这种灵活性。



5。 Docker提供图像的版本控制



我们可以使用docker commit命令。我们可以指定两个标志: -m -a。 -m 标志允许我们指定一个提交消息,就像我们在版本控制系统上提交一样:

  $ sudo docker commit -m添加json gem-aKate Smith
0b2616b0e5a8 ouruser / sinatra:v2
4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c

6。 Docker图像没有状态



在Docker术语中,只读层称为图像。图像永远不会改变。由于Docker使用联合文件系统,因此进程认为整个文件系统都被安装为读写。但是,所有更改都将转到最高层可写层,而只读图像中的原始文件仍未更改。由于图像不变,图像没有状态。



7。虚拟机是以硬件为中心,码头集装箱是以应用为中心的



假设我们有一个大小为1GB的容器映像。如果我们想使用一个完整的虚拟机,我们将需要1GB的x个虚拟机的数目。在docker容器中,我们可以共享1GB的大部分容量,如果您有1000个容器,我们仍然可能只有一个超过1GB的容器操作系统的空间,假设它们都运行相同的操作系统映像。



8。支持的图像格式



Docker图像:




  • 裸。图像没有容器或元数据信封。

  • ovf。 OVF容器格式。

  • aki。一个亚马逊的内核映像。

  • ari。一个亚马逊的ramdisk映像。

  • ami。一个Amazon机器镜像。



虚拟机镜像:




  • 生。非结构化磁盘映像格式;如果你有一个没有
    扩展名的文件,它可能是一个原始格式

  • vhd。 VHD磁盘格式,来自VMware,Xen,
    Microsoft,VirtualBox等虚拟机监视器使用的
    常用磁盘格式

  • vmdk。通常的磁盘格式支持
    许多常见的虚拟机监视器

  • vdi。由VirtualBox
    虚拟机监视器和QEMU仿真器支持

  • iso。存储格式
    用于光盘的数据内容,如CD-ROM。

  • qcow2。
    由QEMU模拟器支持,可以动态扩展,
    支持写入复制

  • aki。一个亚马逊的内核映像。

  • ari。一个Amazon
    的ramdisk映像。

  • ami。亚马逊图像。


Are there any differences in images of Docker and Virtual Machine? Except the image formats, I couldn't find any info on this anywhere. Please comment out on the things like image size, instance creation time, capture time, etc. Thanks!

解决方案

These are some differences between a docker and a VM image which I could list out:

1. Snapshot process is faster in Docker than VMs

We generally start with a base image, and then make our changes, and commit those changes using docker, and it creates an image. This image contains only the differences from the base. When we want to run our image, we also need the base, and it layers our image on top of the base using a layered file system. File system merges the different layers together and we get what we want, and we just need to run it. Since docker typically builds on top of ready-made images from a registry, we rarely have to "snapshot" the whole OS ourself. This ability of Dockers to snapshot the OS into a common image also makes it easy to deploy on other docker hosts.

2. Startup time is less for Docker than VMs

A virtual machine usually takes minutes to start, but containers takes seconds, and sometime even less than a second.

4. Docker images have more portability

Docker images are composed of layers. When we pull or transfer an image, only the layers we haven’t yet in cache are retrieved. That means that if we use multiple images based on the same base Operating System, the base layer is created or retrieved only once. VM images doesn't have this flexibility.

5. Docker provides versioning of images

We can use the docker commit command. We can specify two flags: -m and -a. The -m flag allows us to specify a commit message, much like we would with a commit on a version control system:

$ sudo docker commit -m "Added json gem" -a "Kate Smith"
0b2616b0e5a8 ouruser/sinatra:v2
4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c

6. Docker images do not have states

In Docker terminology, a read-only Layer is called an image. An image never changes. Since Docker uses a Union File System, the processes think the whole file system is mounted read-write. But all the changes go to the top-most writeable layer, and underneath, the original file in the read-only image is unchanged. Since images don't change, images do not have state.

7. VMs are hardware-centric and docker containers are application-centric

Let's say we have a container image that is 1GB in size. If we wanted to use a Full VM, we would need to have 1GB times x number of VMs you want. In docker container we can share the bulk of the 1GB and if you have 1000 containers we still might only have a little over 1GB of space for the containers OS, assuming they are all running the same OS image.

8. Supported image formats

Docker images:

  • bare. The image does not have a container or metadata envelope.
  • ovf. The OVF container format.
  • aki. An Amazon kernel image.
  • ari. An Amazon ramdisk image.
  • ami. An Amazon machine image.

VM images:

  • raw. An unstructured disk image format; if you have a file without an extension it is possibly a raw format
  • vhd. The VHD disk format, a common disk format used by virtual machine monitors from VMware, Xen, Microsoft, VirtualBox, and others
  • vmdk. Common disk format supported by many common virtual machine monitors
  • vdi. Supported by VirtualBox virtual machine monitor and the QEMU emulator
  • iso. An archive format for the data contents of an optical disc, such as CD-ROM.
  • qcow2. Supported by the QEMU emulator that can expand dynamically and supports Copy on Write
  • aki. An Amazon kernel image.
  • ari. An Amazon ramdisk image.
  • ami. An Amazon machine image.

这篇关于VM映像和Docker映像之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆