avatar
Vagrant v.s. Docker# Programming - 葵花宝典
t*k
1
我曾經長期在有輪迴觀的東方宗教修行,現在成為了一個基督徒,近來發覺這兩種不同
的身份,使我對家中的寵物產生很不一樣的感覺。
以前我都經常對著家中的狗思考:“我跟牠究竟有什麼宿世因緣呢?既然蚊子都可以是
我們的父母,那麼這條狗究竟曾經是我的誰呢?” 有一次家中一條大狗死了,我與家
務助理菲律賓姐姐合力將牠搬到政府寵物屍體收集處,我還叫賓姐替牠祈禱,賓姐就將
手指放在狗屍袋上默唸了幾句。
現在我信基督不信輪迴了,但寵物們還是在信仰的層次進入我的思維。看到很多沒有宗
教背景的網友認為做人衹要心地善良、行善積德、對社會多作貢獻已經足夠,這樣的道
德操守並不比基督徒差,何必一定要信耶穌呢?天主教/基督教未免太霸道了等等,有
其他宗教背景的人更會在這個基礎上進一步說明,甚至某些基督徒亦對這種觀點也抱同
情態度。
我在思考網友的這些意見時,想到人們養貓養狗,目的主要為看門防賊、捉老鼠、陪伴
自己、及有些機構用作招徠客戶例如貓咖啡狗店長等。但是,如果這些寵物從來都不親
近不搭理主人,不按主人的意志去生活,認為自己才是家裏的主人,完全不管自己的本
職工作,只熱衷於寵物間互相幫助,盡情偷吃隨處便溺,並招呼街上的流浪貓狗進屋同
居開派對,一起撕碎主人的床單被鋪衣物以製造安樂窩,被主人發現後就聯群咆哮以反
抗其責駡,企圖趕跑主人以鵲巢鳩佔……,你身為主人,你會怎樣對待這些自己曾託付
愛心的寵物呢?這種狀況,是否與人類拒絕承認並服從創造萬物的天主/上帝的情形相
似呢?當然,天主/上帝給我們的是做祂的子女的榮耀,而不是寵物的地位。
想起當初不信輪迴的菲律賓姐姐按我的要求為狗屍祈禱,其內心可能覺得很無奈及滑稽
。雖然信仰是關乎到我們靈魂的終極苦與樂的嚴肅大事,但有時想到這些有趣往事,亦
會忍俊不禁。
avatar
c*1
2
If your purpose is the isolation, I think docker is what you want.
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 Virtual Box (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 can be not very good.
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
example at docs.docker.io on how to make your Dockerfile, it is very
intuitive.
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.
-------------------------------------
1
"Mac, Windows and some Linux distributions cannot natively run Docker at
this time so we help you setup a Ubuntu virtual machine and run Docker
inside of that". So unless you're on a mainstream Linux distro, your app
will run inside docker which itself will run inside a VM. – aleemb Jan 28
at 18:52
3
This is true for Mac and Windows, but since docker 0.7, any linux distro
works fine. If you know of a non-working one, please let me know. Also,
unless you have a Mac or Windows stack (which is unlikely but can happen),
you do not want to run Docker anywhere but on linux. The docker client works
fine on Mac, should work soon on BSD and the daemon will eventually support
BSD, Solaris and Mac. – creack Jan 28 at 20:25
=====================================
Disclaimer: I wrote Vagrant! But because I wrote Vagrant, I spend most of my
time living in the DevOps world includes software like Docker. I work with
a lot of companies using Vagrant and many use Docker, and I see how the two
interplay.
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. In many other scenarios (I discuss
further), it isn't so easy.
It isn't correct to directly compare Vagrant to 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 is a level above Docker in terms of
abstractions, so it isn't a fair comparison in most cases.
Vagrant launches things to run apps/services for the purpose of development.
This can be on VirtualBox, VMware. It can be remote like AWS, OpenStack.
Within those, if you use containers, Vagrant doesn't care, and embraces that
for example. 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 doesn't try to replace Docker here,
it embraces Docker practices.
Docker specifically runs Docker containers. 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. Of course
if you're talking about production or CI, there is no comparison to Vagrant
! Vagrant doesn't live in these environments, and so Docker should be used.
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!
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:
Vagrant can launch VirtualBox, VMware, AWS, OpenStack, etc. machines. It
doesn't matter what you need, Vagrant can launch it. If you are using Docker
, Vagrant can install Docker on any of these so you can use them for that
purpose.
Vagrant is a single workflow for all your projects. 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. If, for example, in the future, a competitor
arises to compete directly with Docker, Vagrant will be able to run that too.
Vagrant works on Windows (back to XP), Mac (back to 10.5), and Linux (back
to kernel 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.
Vagrant knows how to configure some advanced or non-trivial things like
networking and syncing folders. 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.)
. 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.
Vagrant 1.6 has first-class support for docker-based development
environments. This will not launch a virtual machine on Linux, and will
automatically launch a virtual machine on Mac and 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.
To address specific counter arguments that I've heard in favor of using
Docker instead of Vagrant:
"It is less moving parts" - Yes, it can be, if you use Docker exclusively
for every project. Even then, it is sacrificing flexibility for Docker lock-
in. If you ever decide to not use Docker for any project, past, present, or
future, then you'll have more moving parts. If you had used Vagrant, you
have that one moving part that supports the rest.
"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. 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. It is a strange optimization for development
environments. In production, where Docker really shines, I understand the
need to quickly spin up/down containers.
I hope now its clear to see that it is very difficult, and I believe not
correct, to compare Docker to Vagrant. For dev environments, Vagrant is more
abstract, more general. 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.
In conclusion: in highly specific use cases, Docker is certainly a possible
replacement for Vagrant. In most use cases, it is not. Vagrant doesn't
hinder your usage of 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.
Hope this clears things up!
avatar
N*t
3
如果这个创造世界的天主想要造个宠物公园,他应该吸引或捕捉一些心甘情愿永久当
人奴仆或子女的灵魂进驻,就没有反叛的麻烦了。我怀疑他没有这个能力,所以会
有人反叛,不甘心永久当宠物。

我在思考網友的這些意見時,想到人們養貓養狗,目的主要為看門防佟⒆嚼鲜蟆⑴惆
65533;
自己、及有些機構用作招徠客戶例如貓咖啡狗店長等。但是,如果這些寵物從來都不親
近不搭理主人,不按主人的意志去生活,認為自己才是家裏的主人,完全不管自己的本
職工作,只熱衷於寵物間互相幫助,盡情偷吃隨處便溺,並招呼街上的流浪貓狗進屋同
居開派對,一起撕碎主人的床單被鋪衣物以製造安樂窩,被主人發現後就聯群咆哮以反
抗其責駡,企圖趕跑主人以鵲巢鳩佔……,你身為主人,你會怎樣對待這些自己曾託付
愛心的寵物呢?這種狀況,是否與人類拒絕承認並服從創造萬物的天主/上帝的情形相
似呢?當然,天主/上帝給我們的是做祂的子女的榮耀,而不是寵物的地位。

【在 t***k 的大作中提到】
: 我曾經長期在有輪迴觀的東方宗教修行,現在成為了一個基督徒,近來發覺這兩種不同
: 的身份,使我對家中的寵物產生很不一樣的感覺。
: 以前我都經常對著家中的狗思考:“我跟牠究竟有什麼宿世因緣呢?既然蚊子都可以是
: 我們的父母,那麼這條狗究竟曾經是我的誰呢?” 有一次家中一條大狗死了,我與家
: 務助理菲律賓姐姐合力將牠搬到政府寵物屍體收集處,我還叫賓姐替牠祈禱,賓姐就將
: 手指放在狗屍袋上默唸了幾句。
: 現在我信基督不信輪迴了,但寵物們還是在信仰的層次進入我的思維。看到很多沒有宗
: 教背景的網友認為做人衹要心地善良、行善積德、對社會多作貢獻已經足夠,這樣的道
: 德操守並不比基督徒差,何必一定要信耶穌呢?天主教/基督教未免太霸道了等等,有
: 其他宗教背景的人更會在這個基礎上進一步說明,甚至某些基督徒亦對這種觀點也抱同

avatar
c*1
4
Second, the lock-in argument. "If you use Vagrant as an abstraction, you
will not be locked into Docker!". From the point of view of Vagrant, which
is designed to manage machines, this makes perfect sense: aren't containers
just another kind of machine? Just like EC2 and VMWare, we must be careful
not to tie our provisioning tools to any particular vendor! This would
create lock-in - better to abstract it all away with Vagrant. Except this
misses the point of Docker entirely. Docker doesn't provision machines, it
wraps your application in a lightweight portable runtime which can be
dropped anywhere. What runtime you choose for your application has nothing
to do with how you provision your machines! For example it's pretty frequent
to deploy applications to machines which are provisioned by someone else (
for example an EC2 instance deployed by your sysadmin, perhaps using Vagrant
), or to bare metal machines which Vagrant can't provision at all.
Conversely, you may use Vagrant to provision machines which have nothing to
do with developing your application - for example a ready-to-use Windows IIS
box or something. Or you may use Vagrant to provision machines for projects
which don't use Docker - perhaps they use a combination of rubygems and rvm
for dependency management and sandboxing for example.
In summary: Vagrant is for managing machines, Docker is for building and
running application environments.
avatar
c*1
5
I'm the author of Docker.
The short answer is that if you want to manage machines, you should use
Vagrant. And if you want to build and run applications environments, you
should use Docker.
Vagrant is a tool for managing virtual machines. Docker is a tool for
building and deploying applications by packaging them into lightweight
containers. A container can hold pretty much any software component along
with its dependencies (executables, libraries, configuration files etc.),
and execute it in a guaranteed and repeatable runtime environment. This
makes it very easy to build your app once and deploy it anywhere - on your
laptop for testing, then on different servers for live deployment etc.
It's a common misconception that you can only use Docker on Linux. That's
incorrect, you can also install Docker on Mac, and Windows support is
underway. When installed on Mac, Docker bundles a tiny linux VM (25MB on
disk!) which acts as a wrapper for your container. Once installed this is
completely transparent, you can use the docker command-line in exactly the
same way. This gives you the best of both worlds: you can test and develop
your application using containers, which are very lightweight, easy to test
and easy to move around (see for example https://index.docker.io for sharing
reusable containers with the docker community), and you don't need to worry
about the nitty-gritty details of managing virtual machines, which are just
a means to an end anyway.
In theory it's possible to use Vagrant as an abstraction layer for Docker. I
recommend against this for 2 reasons:
avatar
c*1
6
First, Vagrant is not a good abstraction for Docker. Vagrant was designed to
manage virtual machines. Docker was designed to manage an application
runtime. This means that Docker, by design, can interact with an application
in richer ways, and has more information about the application runtime. The
primitives in Docker are processes, log streams, environment variables and
network links between components.
avatar
c*1
7
The primitives in Vagrant are machines, block devices. Vagrant simply sits
lower in the stack, and the only way it can interact with a container is by
pretending it's just another kind of machine, that you can boot and log into
. So, sure, you can type vagrant up with a docker plugin and something
pretty will happen. Is it a substitute for the full breadth of what Docker
can do? Try native Docker for a couple days and see for yourself :)
avatar
w*g
8
如果kernel版本不一样的话docker似乎搞不定。我天天要用一个centos 5.6的vagrant
。机器已经涨到ubuntu 14.04了。

【在 c********1 的大作中提到】
: If your purpose is the isolation, I think docker is what you want.
: 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 Virtual Box (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 can be not very good.
: 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

avatar
d*r
9
好帖,信息多
我在好奇,为啥 Docker 的 community 不自己搞一个 vagrant, 这样就更成体系了
avatar
k*i
10
The kernel should have been backwards compatible. Using the latest kernel on
host OS could theoretically assure the citizenship of docker containers.

vagrant

【在 w***g 的大作中提到】
: 如果kernel版本不一样的话docker似乎搞不定。我天天要用一个centos 5.6的vagrant
: 。机器已经涨到ubuntu 14.04了。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。