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 - 安装和开始使用)