【译文】什么是Docker

What is Docker?

By Tim Butler • 14 May 2015 •

https://www.conetix.com.au/blog/what-is-docker

 

Unless you’ve been living without internet access for the last two years, it would be hard not to at least heard of Docker. But, as an emerging technology not everyone has taken the time to work out what Docker is, where it fits in and how it can benefit you.

近两年,除非你没上过网,否则想要没听说过Docker是很难的。但是,作为一个新兴的技术,不是每个人都会花时间去了解什么是Docker,适合什么领域,能给你带来什么好处。

 

So, what exactly is Docker? Here’s what Docker themselves describe it as:

下面是Docker自己提供的定义:

 

Docker is an open platform for developers and sysadmins of distributed applications.

Docker是一个为开发人员和系统管理员提供的分布式应用程序的开放平台。

 

Essentially, Docker is a container based system for your applications. If you’re used to the concept of virtual servers, Docker provides further levels of abstraction for your application. Here’s a visual representation of how it differs:

本质来说,Docker是一个基于容器技术的系统。如果你熟悉虚拟服务的概念,那么,Docker为你的应用程序提供更高层级的抽象服务。下图展示了两者的区别:

 

Rather than just being one part of the puzzle, Docker provides a number of components and tools to assist with the entire lifecycle management of the application. This includes the container environment, image management and orchestration.

不局限于功能单一的工具,Docker为应用的整个管理生命周期提供了相当多的组件和工具。包括:容器环境、镜像环境 和编配(注5)。

 

Docker started it’s life as an internal project within a hosting company called dotCloud, but quickly took off once they open sourced it in early 2013. Since then, it's benefited from over 15,000 software commits from over 900 contributors.

Docker作为一个内部项目,发起于一个叫做“dotCloud”的托管公司。但是,早在2013年,就被公布了源代码。从那时起,Docker得益于超过15000次软件的提交,以及超过900名贡献者而逐渐壮大。

 

Why use Docker?

为什么使用Docker

 

Now that you have a basic understanding of Docker, there are a number of great reasons to start using it.

现在你已经对Docker有了一个基本的认识,有很多很重要的原因去使用它。

 

It’s very fast. Start a Docker container can be complete in as little as 50ms. That’s not a typo, it really can be this quick! This is the advantage of having such high levels of abstraction, you reduce the number of components you need to run. This also means that there's very little to no overhead in it's implementation.

它启动很快。启动一个Docker容器只需50毫秒。没有看错,是真的这么快。这就是使用高层级抽象的好处,这样减少了你所需运行的组件的数量。这也意味着,在它执行的过程中几乎没有额外的开销。

 

One command deployments. It really is as simple as installing an application with one line. Want to install MySQL? One command. Want WordPress, MySQL, Nginx and Memcache all installed and configured? Yep, it’s one command.

一键(单命令)部署。它是真的简单到安装一个应用只需输入一行命令。想要安装MySQL?一行命令。想到一下子把WordPress, MySQL, Nginx and Memcache全部安装并且配置完成?还是一行命令。

 

Pre-configured Apps. At last count, there were over 13,000 applications already packaged as a Docker image. Chances are, if you’re using a common application then most of the initial work has already been done for you. But, it doesn't end there. You can take the existing image, make your own changes and push it to your own repository for ease of re-deployment.

预配置应用。在上一次统计中,有超过13000个应用已经打包成了Docker镜像。这样的话,如果你正在使用一个通用的应用,则大部分的初始化工作都应经为你事先做好了。还不止这样,你还可以再得到应用镜像之后,进行个性化的修改,再重新部署到你专属的资源库里。

 

Resource Isolation. Previously, if you ran all of your services on the one server then there’s a chance one of them could exhaust all of the server resources. Docker allows you to set, monitor and adjust these on a per application or service basis.

资源隔离。在过去,如果你想运行所有的服务在同一台服务器上,这可能会耗尽服务器的所有资源。Docker允许你基于各自应用或服务,进行设置、监听、调整。

 

Consistency. Docker really is the “write once deploy anywhere” type environment. It removes all of the hassles going from a development to a production environment or similar. Each set of libraries is very tightly coupled to the docker image to ensure the consistency.

一致性。Docker是那种“一次配置各处部署”的环境。它去除了所有从开发环境向生产环境迁移的琐事。每一组类库都跟他的docker镜像紧密结合,来确保一致性。

 

A complete platform. Rather than just being one part of the puzzle, Docker is shaping up to be a complete platform. There’s the base Engine for the containers, the Registry for image management, Compose to orchestrate complex deployments, Swarm for clustering and Machine for provisioning. This is what’s made Docker different from other container implementations, you can manage the entire lifecycle quite easily.

一个完整的平台。Docker正逐渐发展成为一个提供完整功能的平台,而不局限于功能单一的工具。包括:base Engine,容器的基础引擎;Compose,整合编排复杂的部署(注1);Swarm,用以管理Docker集群(注2);Machine,负责供给(注3)。这就是Docker区别于其他容器类型工具的地方,你可以非常轻松地管理系统的整个生命周期。

 

Scale. This is one area where Docker really shines, especially if you have a micro-service based application. Compose and Swarm assist with deploying scalable applications and there’s then third party tools like Kubernetes and Mesos, which both take it to the next level. We’re talking the ability to manage the entire lifecycle with up to millions of containers, so scale isn’t a problem!

扩展性。这也是Docker很亮眼的特性之一,特别是,如果你的项目是基于微服务的。Compose and Swarm用来部署可扩展的应用系统,加上Kubernetes、Mesos等第三方应用,这两方面使服务器的扩展性提高到了更高的层级。我们这里在讨论的“管理整个生命周期”是基于多达数百万级数量的容器的管理能力,所以说,扩展性不会是问题!扩展性。这也是Docker很亮眼的特性之一,特别是,如果你的项目是基于微服务的。Compose and Swarm用来部署可扩展的应用系统,加上Kubernetes、Mesos等第三方应用,这两方面使服务器的扩展性提高到了更高的层级。我们这里在讨论的“管理整个生命周期”是基于多达数百万级数量的容器的管理能力,所以说,扩展性不会是问题!

 

Why not to use Docker

什么情况下不适用docker

 

This probably seems like a strange topic to cover, but like any system it’s important to understand the limitations and alternatives.

这个话题看起来好像有点儿奇怪,但是,了解它的局限性以及有哪些替代方案,对任何系统来说都是很重要的。

 

If it’s not broken then don’t fix it. Are you having issues with your current application deployment? Does it deploy perfectly each time? Do both developers and sysadmins get along perfectly without any blame or bouncing issues back and forth? If you answered yes to all of the questions, then Docker probably isn’t for you.

如果系统的运转没有出现阻塞,则不适合使用Docker你是否对你当前的应用程序的部署存在困扰?它是否每次部署都很顺利?开发人员和系统管理员能够完美地完成各自工作,而没有任何埋怨或是抛出异常吗?如果你的回答是“yes”,则Docker并不适合你。

 

Docker is an emerging platform. This means that there are constant changes and the toolset is constantly evolving. It also means that the “best practices” are also constantly changing, so you need to stay up-to-date with what’s going on. If you want to learn something once and never deal with change, then Docker probably isn’t for you.

Docker还是一个新兴的平台。这意味着将会有不断地变化,相应的一系列工具也在逐渐发展中。还意味着,“最佳体验”的内容页在不断地改变着,所以,你必须保持“与时俱进”。如果你想要一次掌握无需改变,那么Docker并不适合你。Docker还是一个新兴的平台。这意味着将会有不断地变化,相应的一系列工具也在逐渐发展中。还意味着,“最佳体验”的内容页在不断地改变着,所以,你必须保持“与时俱进”。如果你想要一次掌握无需改变,那么Docker并不适合你。

 

You may need to change your architecture design. Docker containers are immutable by design, you need to think about and store persistent data in a separate volume. While this is a good thing when dealing with infrastructure at scale, it also means you need to carefully consider it. There’s also the networking side of things, the IP addresses and hostnames allocated to the container are done so at runtime. You need to design your Docker environment around this and use service discovery to handle it.

你可能会需要修改你的架构设计。Docker容器被设计成是不可变更的,你需要考虑好把持久数据保存在一个独立的分区上。虽然,这对于处理基础架构的扩展性上是件好事,但也意味着你需要慎重考虑一番。在网络方面需要注意的是:用来配置容器的IP地址和主机名,要在运行前设置好。你需要设计你的Docker环境,用“服务发现”来实现它。

 

Not everything is suited to a Docker environment. Just because Docker is cool, it doesn’t mean it works with everything. It really comes into it’s element when you have a micro-service based system or single component. If your application has a lot of low level system calls or needs hardware access then Docker isn’t the platform for you.

并不是所有的应用都适合Docker环境。虽然Docker很酷,也有其局限性。如果你正在做的是一个基于微服务的系统或是一个独立的组件,那么会非常契合。但是,若你的应用程序需要调用很多底层的系统调用,或是硬件接口,则Docker并不适合你。

 

Lastly, Docker isn’t the only application container platform. There’s already rkt (pronounced Rocket) from CoreOS which offers an alternative application container format and associated toolkits. They have a very similar amount of features but a slightly different focus. Canonical (the creators of Ubuntu) have been going down the path of LXD which although isn’t a direct replacement for Docker, it does offer a lot of container based orchestration tools.

最后,Docker并不是唯一的容器应用平台。还有,由CoreOS开发的rkt(发音同Rocket),提供另一套规格的容器应用平台及辅助工具包。他们也有相似的特性,除了某些细小的差别。另外,Canonical(Ubuntu创建者)公司,目前在维护着LXD(注4),尽管不能直接替换Docker(也能够实现相似的功能),也提供了相当多的基于容器的编配(注5)工具。

 

Still excited about Docker? Excellent!

即使这样,还是对Docker感到兴奋?好极了!

 

How do I get started?

我该怎样开始学习Docker呢?

 

When you should start learning about Docker? The answer is now! You can begin with a very basic tutorial on the Docker website, which is a neat interactive guide through the basic commands.

你应该什么时候开始学习Docker呢?答案是现在!你可以在Docker官网上找到很基础的教程,是那种通过基础命令进行的交互式指导。

 

The next step is to get a basic development environment setup on your local machine. Docker have some basic instructions available to get you started. We’ll also be continuing our set of articles on Docker, which will step you all the way from the basics through to real life examples and advanced implementations. Keep checking back on this blog for updates, or follow us via your preferred social media platform.

下一步,是在你的本地环境安装一个基本的开发环境。Docker提供了一些基础的使用说明来帮助你。我们也会在Docker网站上不断地更新文章,来帮助你从基础慢慢引导到真正的应用实例上,直到高端的应用。跟紧我们在论坛上的更新,或是你更喜欢的社会媒体平台。

 

At Conetix, We’re excited about Docker and where it’s heading. We have already started using it for our production systems and we’re launching a Docker optimised hosting platform within the next two months. If you’re interested, keep an eye on our main website for special offers and prizes for the launch.

在Conetix(https://www.conetix.com.au/),我们对Docker及其未来的发展方向感到兴奋。我们已经把Docker应用到了我们的生产系统上。并且,在未来的两个月内,我们将发起一个用Docker优化的主机平台。如果你也感兴趣,请关注我们的网站,会有特别优惠和奖品奉上。

 

====================================

Tim Butler

With nearly 20 years experience in IT, I have worked with systems scaling to many thousands of simultaneous users. My current role involves providing highly available, high performance web, email and VM platforms to larger company and Australian government entities.

作者简介(Time Butler)

从事IT行业近20年,我曾经为成扩展到千上万用户同时使用的系统工作。我现在的工作包括:为大型公司及澳大利亚政府,提供高可用性、高执行效率的网站、email和虚拟机平台。

 

====================================

注1

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.

Compose是一个专为定义和运行多容器Docker应用而开发的工具。使用Compose工具,可以把你的应用的所有服务的配置信息写到一个Compose文件中。然后,只需一个命令,根据你的配置文件,即可创建和启动所有服务。

 

注2

Swarm是Docker公司在2014年12月初新发布的容器管理工具。和Swarm一起发布的Docker管理工具还有Machine以及Compose。

Swarm是一套较为简单的工具,用以管理Docker集群,使得Docker集群暴露给用户时相当于一个虚拟的整体。Swarm使用标准的Docker API接口作为其前端访问入口,换言之,各种形式的Docker Client(dockerclient in go, docker_py, docker等)均可以直接与Swarm通信。Swarm几乎全部用Go语言来完成开发,并且还处于一个Alpha版本,目前在github上发布的版本仅有v0.1.0-rc1。然而Swarm的发展十分快速,功能和特性的变更迭代还非常频繁。因此,可以说Swarm还不推荐被用于生产环境中,但可以肯定的是Swarm是一项很有前途的技术。

 

注3

Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands. You can use Machine to create Docker hosts on your local Mac or Windows box, on your company network, in your data center, or on cloud providers like AWS or Digital Ocean.

You can use Docker Machine to:

l  Install and run Docker on Mac or Windows

l  Provision and manage multiple remote Docker hosts

l  Provision Swarm clusters

Docker Machine是一个工具,帮助你把Docker引擎安装在虚拟主机上,并且使用docker-machine来管理他们。借助Machine,你可以将Docker主机创建在:本地Mac或Windows系统上,你公司的网络上,你的数据中心上,云供应商(如AWS或DigitalOcean)上。

你可以用Docker Machine来:

l  在Mac和Windows上安装和运行Docker

l  提供并管理多重的远端Docker主机

l  提供Swarm集群

 

注4

LXD is a container "hypervisor" and a new user experience for LXC.

Specifically, it's made of three components:

A system-wide daemon (lxd)

A command line client (lxc)

An OpenStack Nova plugin (nova-compute-lxd)

The LXD project was founded and is currently led by Canonical Ltd and Ubuntu with contributions from a range of other companies and individual contributors.

LXD是一个容器“监视器”,也是一个对LXC的新的用户体验。

具体来说,它有包括三个组件:

一个系统级的守护进程(lxd)

一个命令行客户端(lxc)

一个OpenStack Nova插件(nova-compute-lxd)

LXD由Canonical和Ubuntu公司创建和主导,并由其他一些公司和个人贡献者提供维护。

 

注5

编配(英语:Orchestration)描述复杂计算机系统、中间件(middleware)和业务的自动化的安排、协调和管理。

编配通常被讨论为拥有一个与生俱来的(inherent)智能或隐含的(implicitly)自主性,但这更多的是一种愿望或类比,而不是技术上的描述。事实上,编配更多的是自动化技术的影响或部署控制理论的元素的系统。“编配”的说法常常在有关面向服务的架构(Service Oriented Architecture,简称SOA)、虚拟化(virtualization)、服务开通(provisioning)和动态数据中心(dynamic datacenter)的话题的上下文中被讨论。编排在这个意义上说是关于对准与应用程序,数据,和基础设施的商务请求。它通常被作为一个时髦词来使用。一个稍有不同的用法是有关通过万维网服务(web service)交互,协调一个信息的交换的处理过程。(参见面向服务的架构和万维网服务编排(web service choreography))。将编配层(orchestration layer)从服务层(service layer)中分离出来的应用程序,有时候被称为敏捷应用程序(agile applications)。

英语“Orchestration”的本意是是指管弦乐中的配器法,引申为“对事务的合理安排和控制”。计算机行业的大型系统设计领域中借用了这一词汇,并将其翻译成中文“编配”。在计算机领域中,另一个常被一同提及的词汇“编排”(choreography)来源于舞蹈中的编舞。一些文档对“编配”和“编排”做了对比区分。

 

============

生词:

emerging          新兴的,刚出现的

distributed applications  分布式应用程序

Essentially        基本上,本质上

concept             概念

abstract            抽象

representation         表现,描述

rather than                与其,而不是

puzzle                拼图

orchestration  编配

took off              脱(衣、帽、鞋等)

benefited from         受益于

contribute        捐献,贡献

typo                    打字(或排版)错误

overhead          开销

repository         仓库,资源库

Previously         以前

hassle                日常琐事,麻烦

provision           提供,供给

alternative       替代方案

evolve                进化,逐步发展

immutable        不可变的

persistent         持久的

infrastructure  基础架构,基础设施

allocate             部署,分配

service discovery     服务发现

pronounce        发音

orchestration  编配

tutorial              教程

instruction        使用说明

optimise            优化(optimize)

launch                发起

prize                            奖品

simultaneous   同时(发生或进行)的

entity                 实体

specifically        具体来说

system-wide    系统级的

daemon             守护进程

posted @ 2017-02-16 22:57  中年程序员  阅读(2491)  评论(4编辑  收藏  举报