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.
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 provides light-weight virtualization, with almost zero overhead. The effects of this deliver some impactful advantages.
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.
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.
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.
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.
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.
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.
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 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.
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.
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.
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.
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.
原文链接：8 Ways to Use Docker in the Real World（翻译：钟最龙 审校：李颖杰）