微信号:openstacks

介绍:云计算技术的深入分析和解析;计算,存储,网路,SDN,KVM一网打尽......

八个Docker的真实应用场景

2015-01-20 09:34 Devops

8 Ways to Use Docker in the Real World

A couple of weeks ago, we attended DockerCon, the inaugural Docker-centric conference for developers, and anyone else, with an interest in the open platform to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud. We were there, not only as a founding System Integration partner, but also as a presenter.

几周前我们参加了DockerCon ,Dockercon是首个以Docker为中心的技术大会。它面向开发者以及对在Docker开放平台上构建、交付、运行分布式应用感兴趣的从业者,不论这些开放平台是运行于自用笔记本上或者是数据中心的虚拟机上。我们参加了这次大会,Flux7是Docker基础的系统集成合作伙伴,同时也是演讲嘉宾。

Our CEO Aater Suleman gave a joint presentation with one of our customers. While the conference was interesting, I felt it was too driven by implementation and not focused enough on use cases. So, in this post, I thought I’d introduce and share some use cases for Docker.

我们的CEO Aater Suleman和我们的一位客户一同进行了演讲。虽然DockerCon大会十分有趣,但我觉得大会太关注Docker的具体细节,而忽略了Docker的使用场景。所以,在这篇文章中,我想介绍并分享一些Docker的实际应用案例。

Before we can talk about how Docker can be used, let’s see what special capabilities this tool brings to the show.

在我们讨论Docker的使用场景之前,先来看看Docker这个工具有什么特别的地方吧。

Docker provides light-weight virtualization, with almost zero overhead. The effects of this deliver some impactful advantages.

Docker提供了轻量级的虚拟化,它几乎没有任何额外开销,这个特性非常酷。

The first is that you can get the benefits of an extra layer of abstraction offered by Docker without having to worry about the overhead. The second advantage is that you can have many more containers running on a single machine than you can do with virtualization.

首先你在享有Docker带来的虚拟化能力的时候无需担心它带来的额外开销。其次,相比于虚拟机,你可以在同一台机器上创建更多数量的容器

Another powerful impact is that container bringup and bringdown can be accomplished within seconds. Solomon Hykes, founder of Docker Inc., has a great overview of what Docker adds to plain LXCs here.

Docker的另外一个优点是容器的启动与停止都能在几秒中内完成。Docker公司的创始人 Solomon Hykes曾经介绍过Docker在单纯的LXC之上做了哪些事情,你可以去看看。

Here are just some of the use cases that with the enabling technology of Docker provide a consistent environment at a very low overhead.

下面是我总结的一些Docker的使用场景,它为你展示了如何借助Docker的优势,在低开销的情况下,打造一个一致性的环境。


Simplifying Configuration

This is the primary use case Docker Inc. advocates. One of the big advantages of VMs is the ability to run any platform with its own config on top of your infrastructure. Docker provides this same capability without the overhead of a VM. It lets you put your environment and configuration into code and deploy it. The same Docker configuration can be used in a variety of environments. This decouples infrastructure requirements from the application environment.

这是Docker公司宣传的Docker的主要使用场景。虚拟机的最大好处是能在你的硬件设施上运行各种配置不一样的平台(软件、系统),Docker在降低额外开销的情况下提供了同样的功能。它能让你将运行环境和配置放在代码中然后部署,同一个Docker的配置可以在不同的环境中使用,这样就降低了硬件要求和应用环境之间耦合度


Code Pipeline Management

The previous use case makes a large impact in managing the code pipeline. As the code travels from the developer’s machine to production, there are many different environments it has to go through to get there. Each of these may have minor differences. Docker provides a consistent environment to the application from dev through production, easing the code development and deployment pipeline.

前一个场景对于管理代码的流水线起到了很大的帮助。代码从开发者的机器到最终在生产环境上的部署,需要经过很多的中间环境。而每一个中间环境都有自己微小的差别,Docker给应用提供了一个从开发到上线均一致的环境,让代码的流水线变得简单不少


Developer Productivity

This leads to some additional advantages Docker has for a dev productivity use case. For a detailed example of this, you can check out Aater’s talk from DevOpsDays Austin 2014 or DockerCon.

这就带来了一些额外的好处:Docker能提升开发者的开发效率。如果你想看一个详细一点的例子,可以参考Aater在DevOpsDays Austin 2014 大会或者是DockerCon上的演讲。

In a developer environment, we have two goals that are at odds with each other. We want it be as close as possible to production, and we want the development environment to be as fast as possible for interactive use.

不同的开发环境中,我们都想把两件事做好。一是我们想让开发环境尽量贴近生产环境,二是我们想快速搭建开发环境。

Ideally, to achieve the first goal, we need to have every service running on its own VM to reflect how the production application runs. However, we don’t want to always require an Internet connection and add in the overhead of working remotely every time a compilation is needed. This is where the zero-overhead of Docker comes in handy. A development environment usually has a very low memory. And by not adding to the memory footprint that’s commonly done when using a VM, Docker easily allows a few dozen services to run within Docker.

理想状态中,要达到第一个目标,我们需要将每一个服务都跑在独立的虚拟机中以便监控生产环境中服务的运行状态。然而,我们却不想每次都需要网络连接,每次重新编译的时候远程连接上去特别麻烦。这就是Docker做的特别好的地方,开发环境的机器通常内存比较小,之前使用虚拟的时候,我们经常需要为开发环境的机器加内存,而现在Docker可以轻易的让几十个服务在Docker中跑起来。


App Isolation

There may be many reasons for which you end up running multiple applications on the same machine. An example of this is the developer productivity flow described earlier. But there are other cases, too.

有很多种原因会让你选择在一个机器上运行不同的应用,比如之前提到的提高开发效率的场景等。

A couple to consider are server consolidation for decreasing cost or a gradual plan to separate a monolithic application into decoupled pieces. For understanding why it is important to create decoupled applications, read this essay by Steve Yege, who compares Google and Amazon.

我们经常需要考虑两点,一是因为要降低成本而进行服务器整合,二是将一个整体式的应用拆分成松耦合的单个服务(译者注:微服务架构)。如果你想了解为什么松耦合的应用这么重要,请参考Steve Yege的这篇论文,文中将Google和亚马逊做了比较。


Server Consolidation

Just like using VMs for consolidating multiple applications, the application isolation abilities of Docker allow consolidating multiple servers to save on cost. However, without the memory footprint of multiple OSes and the ability to share unused memory across the instances, Docker provides far denser server consolidation than you can get with VMs.

正如通过虚拟机来整合多个应用,Docker隔离应用的能力使得Docker可以整合多个服务器以降低成本。由于没有多个操作系统的内存占用,以及能在多个实例之间共享没有使用的内存,Docker可以比虚拟机提供更好的服务器整合解决方案


Debugging Capabilities

Docker provides a lot of tools that are not necessarily specific to containers, but, they work well with the concept of containers. They also provide extremely useful functionality. This includes the ability to checkpoint and version containers, as well as to diff two containers. This can be immensely useful in fixing an application. You can find an example of this in our “Docker Saves the Day” post.

Docker提供了很多的工具,这些工具不一定只是针对容器,但是却适用于容器。它们提供了很多的功能,包括可以为容器设置检查点、设置版本和查看两个容器之间的差别,这些特性可以帮助调试Bug。你可以在《Docker拯救世界》的文章中找到这一点的例证


Multi-Tenancy

Yet another interesting use case of Docker is its use in multi-tenant applications, thereby avoiding major application rewrites. Our very own multi-tenant example is to develop quick and easy multi-tenancy for an IoT application. Code Bases for such multi-tenant applications are far more complicated, rigid and pretty much difficult to handle. Rearchitecting an application is not only time consuming, but also costs a lot of money.

另外一个Docker有意思的使用场景是在多租户的应用中,它可以避免关键应用的重写。我们一个特别的关于这个场景的例子是为IoT(译者注:物联网)的应用开发一个快速、易用的多租户环境。这种多租户的基本代码非常复杂,很难处理,重新规划这样一个应用不但消耗时间,也浪费金钱

Using Docker, it was easy and inexpensive to create isolated environments for running multiple instances of app tiers for each tenant. This was possible given the spin up speed of Docker environments and it’s effective diff command.

You can learn more about this use case here.

使用Docker,可以为每一个租户的应用层的多个实例创建隔离的环境,这不仅简单而且成本低廉,当然这一切得益于Docker环境的启动速度和其高效的diff命令。

你可以在这里了解关于此场景的更多信息


Rapid Deployment

Before VMs, bringing up a new hardware resource took days. Virtualization brought this number down to minutes. Docker, by creating just a container for the process and not booting up an OS, brings it down to seconds. This is the enabling technology that has had Google and Facebook using containers.

在虚拟机之前,引入新的硬件资源需要消耗几天的时间。Docker的虚拟化技术将这个时间降到了几分钟,Docker只是创建一个容器进程而无需启动操作系统,这个过程只需要秒级的时间。这正是Google和Facebook都看重的特性。

You can create and destroy resources in your data center without worrying about the cost of bringing it up again. With typical data center utilization at 30%, it is not difficult to bump up that number by using a more aggressive allocation of resources. And, the low cost of bringing up a new instance allows for a more aggressive allocation of resources.

你可以在数据中心创建销毁资源而无需担心重新启动带来的开销。通常数据中心的资源利用率只有30%,通过使用Docker并进行有效的资源分配可以提高资源的利用率。

原文链接:8 Ways to Use Docker in the Real World(翻译:钟最龙 审校:李颖杰)

 
Devops 更多文章 The foundation of devops What is DevOps Devops何德何能? Continuous integration (持续集成) 大师经典 — Martin Fowler的"持续集成"
猜您喜欢 想知道应用是否盈利?快去查看应用的收入和买家数据吧 Material Design:扁而不平 Weex详解:移动端高性能动态化方案 华为“HCNP-R&S v2.0南征北战全国行”济南站即将开启 关于C++、PHP和Swoole