首先,什么是 Docker?
Docker is a software tool which allows for operating system level virtualisation, through the use of (mostly) wwwed packages known as containers. This differs from more traditional Virtual Machines, which use hardware virtualisation. To understand Docker will require the understanding of hardware virtualisation and operating system level virtualisation.
操作系统与硬件虚拟化的比较

Hardware Virtualisation, i.e. Virtual Machines, are achieved by running software on a physical server, known as a Hypervisor, which “virtualises” the server’s physical hardware. This Hypervisor enables the ability to run multiple Operating Systems, concurrently and of differing types, on a single server.

操作系统虚拟化(即容器)是通过在物理服务器上运行完整的操作系统,然后在该操作系统中运行容器引擎来实现的。该容器引擎支持操作系统内核(操作系统的核心)与容器内运行的应用程序共享。通过与容器共享操作系统的核心功能,这些容器的大小比传统虚拟机要小得多。
Docker 简史
Docker 最初是一家名为 dotCloud 的平台即服务 (PaaS) 公司,由 Solomon Hykes 和 Sebastien Pahl 于 2011 年创立。这款软件一开始只是一个内部项目,最终于 2013 年在 PyCon 上面向公众首次亮相,同年 3 月作为开源项目发布。此后 Docker 迅速流行起来,由 RedHat(2013 年)和亚马逊云计算服务(2014 年)等公司提供 Docker 商业服务,2014 年与 Stratoscale 和 IBM 建立合作关系。
截至 2018 年,Docker 提供了以下有关其服务全球使用情况的统计数据:

Docker 对你来说意味着什么?
与独立的应用程序和虚拟机相比,Docker 有几个主要的技术优势,其中包括:
- OS agnostic images – Docker containers are built from Docker images, these are OS agnostic and can therefore be deployed on any platform on which the Docker engine can run. This means you can simply and efficiently migrate an application stack (running in Docker containers) which may be running on a Linux server to a Windows server and vice versa, for example.
- Easy server upgrades – Because Docker containers are abstracted from the OS, the host server upgrades can be applied without the requirement to consider whether the application stack will be affected.
- Simple snapshots – Docker containers may be imaged to create snapshots at a point in time of your running applications. This provides the ability to create simple snapshots, which, similar to the running containers, are much smaller in size than a traditional VM image.
- Versioning – Application stacks can be versioned, by utilising the snapshot feature and tagging the created image with the version details. Additionally, the underlying base Dockerfiles from which the images are created can be maintained in a version control system (VCS), as they are simply text files specifying the commands to setup the environment for which the image will be created.
- Ecosystem – Docker provides the Docker Hub, a worldwide library for Docker images, which contains over 100,000 pre-created images across the software spectrum. Most well-known software vendors, such as Microsoft, Oracle and Atlassian contribute to this library, providing official images, complete with documentation, for some of the most common applications used worldwide.
- Central file access – Docker provides the ability to map storage volumes between the container and the host server. This provides the ability to manage the filesystem for an application stack on a single machine, whereas traditionally the filesystem would span multiple VMs.
- Simple application upgrades – Docker containers can be upgraded simply by stopping the current container, removing the current container and running the container relating to the higher version. In order to retain user data, any files should be mapped to a connected Docker volume located on the host machine.
- Simple application configuration changes – Key application settings may be provided as Docker environment variables, passed to the application in the initial Docker run command. This enables the ability to change settings such as heap size for the application, by simply restarting the container with a new value for the relevant environment variable.
- Infrastructure as Code (IaC) – Docker provides the ability to define your application stack and the related networking and storage in a single file, known as a Docker Compose file. This is essentially your IaC and uses the YAML file format, it may therefore be stored in a VCS and versioned appropriately.
在业务层面,已证明在机构内使用 Docker 可以提高以下关键领域的绩效:

Docker 入门
In order to get started with Docker, you will need to consider where your Docker engine(s) will be located. You may choose to run your own Docker engine(s) on your physical or cloud provider’s servers or VMs.
或者,还有许多容器即服务 (CaaS) 产品,例如:
- Amazon Elastic Container Service (ECS)
- Azure Container Service (ACS/AKS)
- Google Kubernetes Engine (GKE)
- Red Hat OpenShift Online
在配置了容器运行的基础设施之后,你需要为你的应用程序堆栈创建或识别相关镜像。你可以从三种方法中进行选择:
- 创建你自己的 Dockerfile
- 扩展当前的 Dockerfile
- 使用现有的 Dockerfile/镜像
最后,配置基础设施并且创建或识别镜像之后,你需要从镜像运行 Docker 容器,确保配置相关的环境变量、网络连接和存储卷。
Docker 和 Kubernetes 是否相同?
简短的回答:不相同。
However, Kubernetes makes use of Docker containers and therefore the two are closely linked. Kubernetes is an orchestration system for containers, providing the ability to manage, place, scale and route. Similarly, Docker provide Docker Swarm as an alternative orchestration system.
想要了解更多信息?请密切关注我们即将发布的关于 Kubernetes 的下一篇博客!