简体   繁体   English

如果docker使用虚拟机在mac上运行那么它比vagrant有什么优势呢?

[英]If docker uses virtual machine to run on a mac then what is its advantage over vagrant?

So I have read this in many places that docker is faster and more efficient because it uses containers over VMs but when I downloaded docker on my mac I realized that it uses virtual box to run the containers. 所以我在很多地方都已经读到这个,因为它使用容器而不是VM,但是当我在我的mac上下载docker时,我意识到它使用虚拟盒来运行容器。 I believe on a linux machine docker doesn't need virtual box and can run on Linux Kernel. 我相信Linux机器上的docker不需要虚拟机,可以在Linux内核上运行。 Is this correct ? 它是否正确 ?

Back to original question. 回到原始问题。 Is docker still faster/efficient because it uses a single VM to run multiple containers as opposed to Vargrant's new VM for every environment ? Docker是否仍然更快/更高效,因为它使用单个VM来运行多个容器,而不是Vargrant针对每个环境的新VM?

I believe on a linux machine docker doesn't need virtual box and can run on Linux Kernel. 我相信Linux机器上的docker不需要虚拟机,可以在Linux内核上运行。 Is this correct ? 它是否正确 ?

Yes, hence the need for a VirtualBox Linux VM (using a TinyCore distribution) 是的,因此需要一个VirtualBox Linux VM(使用TinyCore发行版)

Is docker still faster/efficient because it uses a single VM to run multiple containers as opposed to Vargrant's new VM for every environment ? Docker是否仍然更快/更高效,因为它使用单个VM来运行多个容器,而不是Vargrant针对每个环境的新VM?

Yes, because of the lack of Hypervisor simulating the hardware and OS: here you can launch multiple containers all using directly the kernel (through direct system calls ), without having to simulate an OS. 是的,因为缺少Hypervisor模拟硬件和操作系统:在这里你可以直接使用内核(通过直接系统调用 )启动多个容器,而无需模拟操作系统。
(Note: May 2018, gVisor is another option: a container, simulating an OS!) (注意:2018年5月, gVisor是另一种选择:一个容器,模拟操作系统!)

vm vs容器

See more at " How is Docker different from a normal virtual machine? ". 有关详细信息,请参阅“ Docker与普通虚拟机有何不同之处? ”。

Of course, remember that Vagrant can use a docker provider . 当然,请记住Vagrant可以使用docker提供程序
That means you don't have to always provision a full-fledged VM with Vagrant, but rather images and containers. 这意味着您不必总是使用Vagrant配置成熟的VM,而是配置图像和容器。

Vagrant.configure("2") do |config|
  config.vm.provider "docker" do |d|
    d.image = "foo/bar"
  end
end

See Vagrant docker provisioner . 请参阅Vagrant docker provisioner

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

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