docker_practice/introduction/why.md

64 lines
5.3 KiB
Go
Raw Normal View History

## 为什么要使用 Docker
作为一种新兴的虚拟化方式Docker 跟传统的虚拟化方式相比具有众多的优势
2019-08-11 10:49:23 +00:00
## Why use Docker ?
As a new virtualization solution, Docker has many advantager over
other traditional virtualization solutions.
### 更高效的利用系统资源
由于容器不需要进行硬件虚拟以及运行完整操作系统等额外开销Docker 对系统资源的利用率更高无论是应用执行速度内存损耗或者文件存储速度都要比传统虚拟机技术更高效因此相比虚拟机技术一个相同配置的主机往往可以运行更多数量的应用
2019-08-11 10:49:23 +00:00
### Use System Resources more efficiently
Docker has high utilization rate of system resources, because container does not need additional overhead such as hardware virtualization and running the whole system. It's more efficient than traditional virtual machine technology in application executing speed, memory expend and file storage speed. Therefore, a host with the same configuration can often run more applications than virtual machine technology.
### 更快速的启动时间
传统的虚拟机技术启动应用服务往往需要数分钟 Docker 容器应用由于直接运行于宿主内核无需启动完整的操作系统因此可以做到秒级甚至毫秒级的启动时间大大的节约了开发测试部署的时间
2019-08-11 10:49:23 +00:00
### Faster startup time
The traditional virtual machine technology needs minutes to startup application service, but Docker can do it in seconds or milliseconds due to running on the kernel of host machine and not running the whole system. It saves a considerable amount of time for developing, testing, deploying.
### 一致的运行环境
2017-09-04 14:06:11 +00:00
开发过程中一个常见的问题是环境一致性问题由于开发环境测试环境生产环境不一致导致有些 bug 并未在开发过程中被发现 Docker 的镜像提供了除内核外完整的运行时环境确保了应用运行环境一致性从而不会再出现 *这段代码在我机器上没问题啊* 这类问题
2019-08-11 10:49:23 +00:00
### Consistent operating environment
The consensus problem of environment is a common problem in developing. It causes some bugs which weren't found at developing due to different environments of developing, testing, production. Docker's image provides a complete runtime environment without kernel, which ensures consistency of the application runtime environment so that problmes like * This piece of code is okey on my machine * do not recur.
### 持续交付和部署
对开发和运维[DevOps](https://zh.wikipedia.org/wiki/DevOps))人员来说,最希望的就是一次创建或配置,可以在任意地方正常运行。
2019-08-11 10:49:23 +00:00
### CI/CD
For development and operation[DevOps](https://zh.wikipedia.org/wiki/DevOps)people, desirable thing is to create or configure at once and run normally anywhere.
2017-11-22 12:28:10 +00:00
使用 Docker 可以通过定制应用镜像来实现持续集成持续交付部署开发人员可以通过 [Dockerfile](../image/dockerfile/) 来进行镜像构建并结合 [持续集成(Continuous Integration)](https://en.wikipedia.org/wiki/Continuous_integration) 系统进行集成测试,而运维人员则可以直接在生产环境中快速部署该镜像,甚至结合 [持续部署(Continuous Delivery/Deployment)](https://en.wikipedia.org/wiki/Continuous_delivery) 系统进行自动部署。
2019-08-11 10:49:23 +00:00
CI/CD can be achieved by customizing application mirrors with Docker. Developers can build images with [Dockerfile](../image/dockerfile/) and use [Continuous Integration](https://en.wikipedia.org/wiki/Continuous_integration) for integration testing. Operators can deply product environment quickly with this images, even use [Continuous Delivery/Deployment](https://en.wikipedia.org/wiki/Continuous_delivery) for automatic deployment.
而且使用 `Dockerfile` 使镜像构建透明化不仅仅开发团队可以理解应用运行环境也方便运维团队理解应用运行所需条件帮助更好的生产环境中部署该镜像
### 更轻松的迁移
由于 Docker 确保了执行环境的一致性使得应用的迁移更加容易Docker 可以在很多平台上运行无论是物理机虚拟机公有云私有云甚至是笔记本其运行结果是一致的因此用户可以很轻易的将在一个平台上运行的应用迁移到另一个平台上而不用担心运行环境的变化导致应用无法正常运行的情况
### 更轻松的维护和扩展
2018-12-14 11:08:14 +00:00
Docker 使用的分层存储以及镜像的技术使得应用重复部分的复用更为容易也使得应用的维护更新更加简单基于基础镜像进一步扩展镜像也变得非常简单此外Docker 团队同各个开源项目团队一起维护了一大批高质量的 [官方镜像](https://hub.docker.com/search/?type=image&image_filter=official),既可以直接在生产环境使用,又可以作为基础进一步定制,大大的降低了应用服务的镜像制作成本。
2014-10-03 03:34:57 +00:00
### 对比传统虚拟机总结
| 特性 | 容器 | 虚拟机 |
2017-11-24 08:50:25 +00:00
| :-------- | :-------- | :---------- |
| 启动 | 秒级 | 分钟级 |
2017-11-24 04:32:36 +00:00
| 硬盘使用 | 一般为 `MB` | 一般为 `GB` |
| 性能 | 接近原生 | 弱于 |
2014-10-03 03:34:57 +00:00
| 系统支持量 | 单机支持上千个容器 | 一般几十个 |