Docker: the Linux container engine

原文地址:https://github.com/dotcloud/docker/

Docker教程中文版本:http://www.widuu.com/docker/

Docker is an open source project to pack, ship and run any application as a lightweight container

Docker containers are both hardware-agnostic and platform-agnostic. This means that they can run anywhere, from your laptop to the largest EC2 compute instance and everything in between - and they don't require that
you use a particular language, framework or packaging system. That makes them great building blocks for deploying and scaling web apps, databases and backend services without depending on a particular stack or provider.

Docker is an open-source implementation of the deployment engine which powers dotCloud, a popular Platform-as-a-Service. It benefits directly
from the experience accumulated over several years of large-scale operation and support of hundreds of thousands of applications and databases.

Better
than VMs

A common method for distributing applications and sandboxing their execution is to use virtual machines, or VMs. Typical VM formats are VMWare's vmdk, Oracle Virtualbox's vdi, and Amazon EC2's ami. In theory these formats should allow every developer to automatically
package their application into a "machine" for easy distribution and deployment. In practice, that almost never happens, for a few reasons:

  • Size: VMs are very large which makes them impractical to store and transfer.
  • Performance: running VMs consumes significant CPU and memory, which makes them impractical in many scenarios, for example local development of multi-tier applications, and large-scale deployment of cpu and memory-intensive
    applications on large numbers of machines.
  • Portability: competing VM environments don't play well with each other. Although conversion tools do exist, they are limited and add even more overhead.
  • Hardware-centric: VMs were designed with machine operators in mind, not software developers. As a result, they offer very limited tooling for what developers need most: building, testing and running their software. For example,
    VMs offer no facilities for application versioning, monitoring, configuration, logging or service discovery.

By contrast, Docker relies on a different sandboxing method known as containerization. Unlike traditional virtualization, containerization takes place at the kernel level. Most modern operating system kernels now support the primitives
necessary for containerization, including Linux with openvzvserver and
more recently lxc, Solaris with zones and
FreeBSD with Jails.

Docker builds on top of these low-level primitives to offer developers a portable format and runtime environment that solves all 4 problems. Docker containers are small (and their transfer can be optimized with layers), they have basically zero memory and cpu
overhead, they are completely portable and are designed from the ground up with an application-centric design.

The best part: because Docker operates at the OS level, it can still be run inside a VM!

Plays
well with others

Docker does not require that you buy into a particular programming language, framework, packaging system or configuration language.

Is your application a Unix process? Does it use files, tcp connections, environment variables, standard Unix streams and command-line arguments as inputs and outputs? Then Docker can run it.

Can your application's build be expressed as a sequence of such commands? Then Docker can build it.

Escape
dependency hell

A common problem for developers is the difficulty of managing all their application's dependencies in a simple and automated way.

This is usually difficult for several reasons:

  • Cross-platform dependencies. Modern applications often depend on a combination of system libraries and binaries, language-specific packages, framework-specific modules, internal components
    developed for another project, etc. These dependencies live in different "worlds" and require different tools - these tools typically don't work well with each other, requiring awkward custom integrations.
  • Conflicting dependencies. Different applications may depend on different versions of the same dependency. Packaging tools handle these situations with various degrees of ease - but they all handle them in different
    and incompatible ways, which again forces the developer to do extra work.
  • Custom dependencies. A developer may need to prepare a custom version of their application's dependency. Some packaging systems can handle custom versions of a dependency, others can't - and all of them handle
    it differently.

Docker solves dependency hell by giving the developer a simple way to express all their application's dependencies in one place, and streamline the process of assembling them. If this makes you think of XKCD
927
, don't worry. Docker doesn't replace your favorite packaging systems. It simply orchestrates their use in a simple and repeatable way. How does it do that? With layers.

Docker defines a build as running a sequence of Unix commands, one after the other, in the same container. Build commands modify the contents of the container (usually by installing new files on the filesystem), the next command modifies it some more, etc.
Since each build command inherits the result of the previous commands, the order in which the commands are executed expresses dependencies.

Here's a typical Docker build process:

FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -q -y python python-pip curl
RUN curl -L https://github.com/shykes/helloflask/archive/master.tar.gz | tar -xzv
RUN cd helloflask-master && pip install -r requirements.txt

Note that Docker doesn't care how dependencies are built - as long as they can be built by running a Unix command in a container.

Getting
started

Docker can be installed on your local machine as well as servers - both bare metal and virtualized. It is available as a binary on most modern Linux systems, or as a VM on Windows, Mac and other systems.

We also offer an interactive tutorial for quickly learning the basics of using Docker.

For up-to-date install instructions and online tutorials, see the Getting Started page.

Usage
examples

Docker can be used to run short-lived commands, long-running daemons (app servers, databases etc.), interactive shell sessions, etc.

You can find a list of real-world examples in the documentation.

Under
the hood

Under the hood, Docker is built on the following components:

  • The cgroup and namespacing capabilities
    of the Linux kernel;
  • The Go programming language.

Contributing
to Docker

Want to hack on Docker? Awesome! There are instructions to get you started here.

They are probably not perfect, please let us know if anything feels wrong or incomplete.

Legal

Brought to you courtesy of our legal counsel. For more context, please see the Notice document.

Use and transfer of Docker may be subject to certain restrictions by the United States and other governments.
It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see http://www.bis.doc.gov

Licensing

Docker is licensed under the Apache License, Version 2.0. See LICENSE for full license text.

时间: 2024-08-07 13:19:20

Docker: the Linux container engine的相关文章

在 Ubuntu 中用 Docker 管理 Linux Container 容器

在 Ubuntu 中用 Docker 管理 Linux Container 容器 当前,完全硬件虚拟化技术(KVM.Xen.Hyper-V 等)能在一个物理主机上很好地运行多个互相独立的操作系统,但这也带来一些问题:性能不佳,资源浪费,系统反应迟缓等.有时候对用户来说,完全的硬件虚拟化并不是最好的选择. 一种替代方案是使用轻量级虚拟化技术 -- 所谓的 LinuX Container 容器 (LXC),它提供的是系统级虚拟化.与跑虚拟机相比,LXC 可以在一个轻量级沙箱容器里面跑多个 Linux

Docker on Google App Engine

Docker on Google App Engine Ekaterina Volkova Software Enginee 1 Deploy a simple app, look at the tools App Engine provides 2 Deploy a more complex app that really does something 3 Look at Local Development experience Docker on Google App Engine

don't touch /var/lib/docker during run container else ERROR: device or resource busy

我用的环境是CentOS 6.5 x64, docker-io-1.1.2-1版本. docker-io包来自EPEL,  [epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epe

新手指南:通过 Docker 在 Linux 上托管 .NET Core

我是首次接触 Docker 并且距离成为一名 Linux 高手还有很远的一段路程.因此,这里的很多想法是来自一个新手. 安装 按照 https://www.microsoft.com/net/core 上的介绍在你的电脑上安装 .NET Core .这将会同时在 Windows 上安装 dotnet 命令行工具以及最新的 Visual Studio 工具. 源代码 你可以直接到 GitHub 上找最到最新完整的源代码. 转换到 .NET CORE 1.0 自然地,当我考虑如何把 API 从 .N

通过Docker在Linux上托管.NET Core

这篇文章基于我之前的文章 .NET Core 入门.首先,我把 RESTful API 从 .NET Core RC1 升级到了 .NET Core 1.0,然后,我增加了对 Docker 的支持并描述了如何在 Linux 生产环境里托管它. 我是首次接触 Docker 并且距离成为一名 Linux 高手还有很远的一段路程.因此,这里的很多想法是来自一个新手. 安装 按照 https://www.microsoft.com/net/core 上的介绍在你的电脑上安装 .NET Core .这将会

GO语言的开源库

Indexes and search engines These sites provide indexes and search engines for Go packages: godoc.org gowalker gosearch Sourcegraph Contributing To edit this page you must be a contributor to the go-wiki project. To get contributor access, send mail t

阿里技术专家:持续交付与微服务背后的实践逻辑

讲师介绍 崔力强 阿里巴巴技术专家   <微服务设计>中文译者之一:曾在ThoughtWorks任职软件交付和敏捷顾问: 对持续集成.自动化测试有丰富经验:目前专注于持续交付SaaS产品的开发,提供精益需求管理.软件设计.敏捷转型相关咨询服务.    前言 大家好,我是崔力强.目前在阿里巴巴任职.负责一款持续交付领域的SaaS产品的开发.非常高兴能够和大家分享持续交付和微服务的话题. 本次分享的重点是持续交付.也会提到一些微服务的概念,以及持续交付和微服务之间的关系.今天会涉及的一些实践可能大

Linux内核bug引起Mesos、Kubernetes、Docker的TCP/IP数据包失效

本文讲的是Linux内核bug引起Mesos.Kubernetes.Docker的TCP/IP数据包失效,[编者的话]最近发现Linux内核bug,会造成使用veth设备进行路由的容器(例如Docker on IPv6.Kubernetes.Google Container Engine和Mesos)不检查TCP校验码(checksum),这会造成应用在某些场合下,例如坏的网络设备,接收错误数据.这个bug可以在三年前任何一个测试过的内核版本中发现.补丁已经被整合进核心代码,正在回迁入3.14之

Docker增强Container的安全性

本文讲的是Docker增强Container的安全性[编者的话]Docker公司公布了他们最近新推出的安全扫描技术,此技术用于改善Docker容器安全性并且已经在Docker Cloud上上线.通过安全扫描技术可以大大改善目前Docker容器在安全上的不足. 本周Docker宣布他们推出了新的安全扫描技术,此技术用于在整个软件供应链中保障容器内容. Docker安全扫描是Docker云私有仓库计划的一个可选服务.它提供对容器镜像内的软件安全性评估. Docker宣称,在整个软件供应链过程中会启用