本文介绍了我应该使用 Vagrant 还是 Docker 来创建隔离环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Ubuntu 进行开发和部署,并且有创建隔离环境的需求.

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

为此我正在考虑使用 Vagrant 或 Docker.优缺点是什么,或者这些解决方案如何比较?

I am considering either Vagrant or Docker for this purpose. What are the pros and cons, or how do these solutions compare?

推荐答案

如果你的目的是隔离,我认为 Docker 就是你想要的.

If your purpose is the isolation, I think Docker is what you want.

Vagrant 是一个虚拟机管理器.它允许您编写虚拟机配置以及供应的脚本.然而,它仍然是一个依赖于 VirtualBox(或其他)的虚拟机,具有巨大的开销.它需要你有一个可能很大的硬盘驱动器文件,它需要很多内存,而且性能可能不是很好.

Vagrant is a virtual machine manager. It allows you to script the virtual machine configuration as well as the provisioning. However, it is still a virtual machine depending on VirtualBox (or others) with a huge overhead. It requires you to have a hard drive file that can be huge, it takes a lot of ram, and performance may be not very good.

另一方面,Docker 通过 LXC 使用内核 cgroup 和命名空间.这意味着您使用与主机相同的内核和相同的文件系统.您可以将 Dockerfile 与 docker build 命令结合使用,以处理容器的供应和配置.您在 docs.docker.com 上有一个关于如何制作 Dockerfile 的示例;它非常直观.

Docker on the other hand uses kernel cgroup and namespacing via LXC. It means that you are using the same kernel as the host and the same file system.You can use Dockerfile with the docker build command in order to handle the provisioning and configuration of your container. You have an example at docs.docker.com on how to make your Dockerfile; it is very intuitive.

你想要使用 Vagrant 的唯一原因是你需要在你的 Ubuntu 机器上进行 BSD、Windows 或其他非 Linux 开发.否则,请选择 Docker.

The only reason you could want to use Vagrant is if you need to do BSD, Windows or other non-Linux development on your Ubuntu box. Otherwise, go for Docker.

这篇关于我应该使用 Vagrant 还是 Docker 来创建隔离环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 12:35