Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
844 views
in Technique[技术] by (71.8m points)

vagrant - 我应该使用Vagrant还是Docker来创建一个孤立的环境? [关闭](Should I use Vagrant or Docker for creating an isolated environment? [closed])

I use Ubuntu for development and deployment and have a need for creating an isolated environment.

(我使用Ubuntu进行开发和部署,并且需要创建一个隔离的环境。)

I am considering either Vagrant or Docker for this purpose.

(我正在考虑为此目的使用Vagrant或Docker。)

What are the pros and cons, or how do these solutions compare?

(有哪些优点和缺点,或者这些解决方案如何比较?)

  ask by murtaza52 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Disclaimer: I wrote Vagrant!

(免责声明:我写了Vagrant!)

But because I wrote Vagrant, I spend most of my time living in the DevOps world which includes software like Docker.

(但是因为我写了Vagrant,我把大部分时间都花在DevOps世界中,其中包括像Docker这样的软件。)

I work with a lot of companies using Vagrant and many use Docker, and I see how the two interplay.

(我和很多使用Vagrant的公司合作,很多人使用Docker,我看到两者如何相互影响。)

Before I talk too much, a direct answer: in your specific scenario (yourself working alone, working on Linux, using Docker in production), you can stick with Docker alone and simplify things.

(在我说太多之前,直接回答:在您的特定场景中(您自己独立工作,在Linux上工作,在生产中使用Docker),您可以单独使用Docker并简化操作。)

In many other scenarios (I discuss further), it isn't so easy.

(在许多其他情况下(我进一步讨论),它并不那么容易。)

It isn't correct to directly compare Vagrant to Docker.

(直接将Vagrant与Docker进行比较是不正确的。)

In some scenarios, they do overlap, and in the vast majority, they don't.

(在某些情况下,它们确实重叠,而在绝大多数情况下,它们不会重叠。)

Actually, the more apt comparison would be Vagrant versus something like Boot2Docker (minimal OS that can run Docker).

(实际上,Vagrant与Boot2Docker(可以运行Docker的最小操作系统)之类的比较更为贴切。)

Vagrant is a level above Docker in terms of abstractions, so it isn't a fair comparison in most cases.

(在抽象方面,Vagrant比Docker高出一个级别,因此在大多数情况下这不是一个公平的比较。)

Vagrant launches things to run apps/services for the purpose of development.

(Vagrant推出用于开发目的的应用程序/服务。)

This can be on VirtualBox, VMware.

(这可以在VirtualBox,VMware上。)

It can be remote like AWS, OpenStack.

(它可以像AWS,OpenStack一样远程。)

Within those, if you use containers, Vagrant doesn't care, and embraces that: it can automatically install, pull down, build, and run Docker containers, for example.

(在这些内容中,如果您使用容器,Vagrant并不关心,并且包含:例如,它可以自动安装,下拉,构建和运行Docker容器。)

With Vagrant 1.6, Vagrant has docker-based development environments , and supports using Docker with the same workflow as Vagrant across Linux, Mac, and Windows.

(借助Vagrant 1.6,Vagrant拥有基于docker的开发环境 ,并支持在Linux,Mac和Windows上使用与Vagrant相同的工作流程。)

Vagrant doesn't try to replace Docker here, it embraces Docker practices.

(Vagrant并不试图在这里取代Docker,它包含了Docker的做法。)

Docker specifically runs Docker containers.

(Docker专门运行Docker容器。)

If you're comparing directly to Vagrant: it is specifically a more specific (can only run Docker containers), less flexible (requires Linux or Linux host somewhere) solution.

(如果您直接与Vagrant进行比较:它具体是一个更具体的(只能运行Docker容器),灵活性较低(需要Linux或Linux主机某处)解决方案。)

Of course if you're talking about production or CI, there is no comparison to Vagrant!

(当然,如果你在谈论生产或CI,那么就没有与Vagrant相比!)

Vagrant doesn't live in these environments, and so Docker should be used.

(Vagrant不会生活在这些环境中,所以应该使用Docker。)

If your organization runs only Docker containers for all their projects and only has developers running on Linux, then okay, Docker could definitely work for you!

(如果您的组织只为其所有项目运行Docker容器,并且只有开发人员在Linux上运行,那么,Docker绝对可以为您工作!)

Otherwise, I don't see a benefit to attempting to use Docker alone, since you lose a lot of what Vagrant has to offer, which have real business/productivity benefits:

(否则,我认为单独使用Docker并没有什么好处,因为你失去了很多Vagrant所提供的东西,这些东西具有真正的业务/生产力优势:)

  • Vagrant can launch VirtualBox, VMware, AWS, OpenStack, etc. machines.

    (Vagrant可以推出VirtualBox,VMware,AWS,OpenStack等机器。)

    It doesn't matter what you need, Vagrant can launch it.

    (无论您需要什么,Vagrant都可以推出它。)

    If you are using Docker, Vagrant can install Docker on any of these so you can use them for that purpose.

    (如果您使用的是Docker,Vagrant可以在其??中任何一个上安装Docker,以便您可以将它们用于此目的。)

  • Vagrant is a single workflow for all your projects.

    (Vagrant是所有项目的单一工作流程。)

    Or to put another way, it is just one thing people have to learn to run a project whether it is in a Docker container or not.

    (或者换句话说,无论是否在Docker容器中,人们必须学会运行项目。)

    If, for example, in the future, a competitor arises to compete directly with Docker, Vagrant will be able to run that too.

    (例如,如果将来竞争对手出现与Docker直接竞争,Vagrant也能够运行。)

  • Vagrant works on Windows (back to XP), Mac (back to 10.5), and Linux (back to kernel 2.6).

    (Vagrant适用于Windows(返回XP),Mac(返回10.5)和Linux(返回内核2.6)。)

    In all three cases, the workflow is the same.

    (在所有三种情况下,工作流程都是相同的。)

    If you use Docker, Vagrant can launch a machine (VM or remote) that can run Docker on all three of these systems.

    (如果您使用Docker,Vagrant可以启动可以在所有这三个系统上运行Docker的计算机(VM或远程)。)

  • Vagrant knows how to configure some advanced or non-trivial things like networking and syncing folders.

    (Vagrant知道如何配置一些高级或非平凡的东西,如网络和同步文件夹。)

    For example: Vagrant knows how to attach a static IP to a machine or forward ports, and the configuration is the same no matter what system you use (VirtualBox, VMware, etc.) For synced folders, Vagrant provides multiple mechanisms to get your local files over to the remote machine (VirtualBox shared folders, NFS, rsync, Samba [plugin], etc.).

    (例如:Vagrant知道如何将静态IP连接到计算机或转发端口,无论您使用什么系统(VirtualBox,VMware等),配置都是相同的。对于同步文件夹,Vagrant提供多种机制来获取本地文件到远程机器(VirtualBox共享文件夹,NFS,rsync,Samba [插件]等)。)

    If you're using Docker, even Docker with a VM without Vagrant, you would have to manually do this or they would have to reinvent Vagrant in this case.

    (如果您正在使用Docker,即使是没有Vagrant的VM的Docker,您也必须手动执行此操作,否则他们必须在这种情况下重新发明Vagrant。)

  • Vagrant 1.6 has first-class support for docker-based development environments .

    (Vagrant 1.6拥有对基于docker的开发环境的一流支持。)

    This will not launch a virtual machine on Linux, and will automatically launch a virtual machine on Mac and Windows.

    (这不会在Linux上启动虚拟机,并将在Mac和Windows上自动启动虚拟机。)

    The end result is that working with Docker is uniform across all platforms, while Vagrant still handles the tedious details of things such as networking, synced folders, etc.

    (最终结果是使用Docker在所有平台上都是统一的,而Vagrant仍然处理诸如网络,同步文件夹等事情的繁琐细节。)

To address specific counter arguments that I've heard in favor of using Docker instead of Vagrant:

(为了解决我听到的支持使用Docker而不是Vagrant的特定反驳论点:)

  • "It is less moving parts" - Yes, it can be, if you use Docker exclusively for every project.

    (“这是不太活跃的部分” - 是的,如果你专门为每个项目使用Docker,它可以。)

    Even then, it is sacrificing flexibility for Docker lock-in.

    (即便如此,它还是牺牲了Docker锁定的灵活性。)

    If you ever decide to not use Docker for any project, past, present, or future, then you'll have more moving parts.

    (如果您决定不将Docker用于过去,现在或未来的任何项目,那么您将拥有更多移动部件。)

    If you had used Vagrant, you have that one moving part that supports the rest.

    (如果您使用过Vagrant,那么您就拥有了一个支撑其余部分的移动部件。)

  • "It is faster!"

    (“它更快!”)

    - Once you have the host that can run Linux containers, Docker is definitely faster at running a container than any virtual machine would be to launch.

    ( - 一旦你拥有可以运行Linux容器的主机,Docker在运行容器方面肯定比任何虚拟机都要快。)

    But launching a virtual machine (or remote machine) is a one-time cost.

    (但启动虚拟机(或远程机器)是一次性成本。)

    Over the course of the day, most Vagrant users never actually destroy their VM.

    (在一天中,大多数Vagrant用户从未真正销毁他们的VM。)

    It is a strange optimization for development environments.

    (这对于开发环境来说是一种奇怪的优化。)

    In production, where Docker really shines, I understand the need to quickly spin up/down containers.

    (在Docker真正发光的生产中,我理解需要快速启动/减少容器。)

I hope now its clear to see that it is very difficult, and I believe not correct, to compare Docker to Vagrant.

(我希望现在可以清楚地看到,将Docker与Vagrant进行比较是非常困难的,而且我认为这是不正确的。)

For dev environments, Vagrant is more abstract, more general.

(对于开发环境,Vagrant更抽象,更通用。)

Docker (and the various ways you can make it behave like Vagrant) is a specific use case of Vagrant, ignoring everything else Vagrant has to offer.

(Docker(以及使其表现得像Vagrant的各种方式)是Vagrant的特定用例,忽略了Vagrant提供的所有其他功能。)

In conclusion: in highly specific use cases, Docker is certainly a possible replacement for Vagrant.

(总结:在高度特定的用例中,Docker肯定是Vagrant的可能替代品。)

In most use cases, it is not.

(在大多数用例中,事实并非如此。)

Vagrant doesn't hinder your usage of Docker;

(Vagrant不会妨碍您使用Docker;)

it actually does what it can to make that experience smoother.

(它实际上做了它可以使体验更顺畅的事情。)

If you find this isn't true, I'm happy to take suggestions to improve things, since a goal of Vagrant is to work equally well with any system.

(如果您发现这不是真的,我很乐意接受改进建议,因为Vagrant的目标是与任何系统同等运作。)

Hope this clears things up!

(希望这能搞定!)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...