Docker - 安装和开始使用

概念

Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. The use of Linux containers to deploy applications is called containerization. Containers are not new, but their use for easily deploying applications is.

Docker是一个开发、部署和运行应用程序的平台,这个过程被称为“容器化”。Docker拥有众多优秀的特性。

  • Flexible: Even the most complex applications can be containerized.
  • Lightweight: Containers leverage and share the host kernel.
  • Interchangeable: You can deploy updates and upgrades on-the-fly.
  • Portable: You can build locally, deploy to the cloud, and run anywhere.
  • Scalable: You can increase and automatically distribute container replicas.
  • Stackable: You can stack services vertically and on-the-fly.

这些优秀特性包括,灵活性,轻量性,通用性,可扩展性和可叠加性。

An image is an executable package that includes everything needed to run an application--the code, a runtime, libraries, environment variables, and configuration files.

镜像包含了一个应用程序所需要的全部文件,二进制代码,运行时库,环境变量定义和配置文件等。

A container is a runtime instance of an image--what the image becomes in memory when executed (that is, an image with state, or a user process)

容器是镜像的运行实体,镜像被载入内存成为容器,同时容器包含了运行状态。

镜像的概念类似于程序,容器则类似于进程。

容器化将计算机的资源“虚拟化”出来,使得应用程序不再依赖特定的某一台计算机及其环境,而是运行在“虚拟化”后组合出来的计算资源(例如"云",“集群”等)之上。

Docker与虚拟机(VM)

A container runs natively on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight.

A virtual machine (VM) runs a full-blown “guest” operating system with virtual access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need.

Docker和虚拟机一样,对实体计算机的资源进行虚拟化,但是它们存在一些差别。容器运行在本地计算机内核之上,而虚拟机是在本地计算机上建立一系列独立的“虚拟计算机”。在容器中运行应用程序不需要太多额外的计算机资源,而在虚拟机中运行,需要的是事先分配的所有资源。

容器应用程序的架构
虚拟机应用程序的架构
## List Docker CLI commands
docker
docker container --help

## Display Docker version and info
docker --version
docker version
docker info

## Execute Docker image
docker run hello-world

## List Docker images
docker image ls

## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq

用Docker运行应用程序有众多优势,

  • applications have no system dependencies
  • updates can be pushed to any part of a distributed application
  • resource density can be optimized.

应用程序和运行环境之间的依赖可以打包,应用程序的分发更加便利,运行应用程序的资源可以调整。而相比虚拟机,容器更加轻量级,需要的计算机资源更少。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、Docker 简介 Docker 两个主要部件:Docker: 开源的容器虚拟化平台Docker Hub: 用...
    R_X阅读 4,406评论 0 27
  • 陌上玫瑰阅读 225评论 0 3
  • 回望这个7月,我发现我停止了不少的活动,一停止就在这月内没有了继续。 1.运动 有坚持过一段时间的晚上慢跑或者慢走...
    mi穿衣服的刺猬阅读 304评论 2 1
  • ✿大一刚开始,由于自己连续几天高烧,便不得不离开军训场回家,后来又可能是因为自己想要逃避军训的煎熬,便选择了见习。...
    树深时见鹿_59a9阅读 148评论 0 0