What is Docker? (什么是 Docker?)

发布时间:2026/6/23 6:16:38
What is Docker? (什么是 Docker?) What is Docker? {什么是 Docker}1. Docker architecture1.1. Docker objects1.2. The Docker daemon1.3. The Docker client1.4. Docker Desktop1.5. Docker registries2. Docker vs. Virtual Machines3. Getting started with Containers4. DockerfileReferencesWhat Is Docker?https://docs.docker.com/get-started/docker-overview/https://www.oracle.com/uk/cloud/cloud-native/container-registry/what-is-docker/Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production.Docker is an open source, standard software platform that helps developers build, test, and deploy containerized applications quickly.Docker 是一个开源、标准化的软件平台可帮助开发人员快速构建、测试和部署容器化应用。Docker is an open source platform that allows developers and systems administrators to package applications into containers. Those containers can then be pushed onto a deployment platform, such as on-premises servers or servers in the cloud, and then executed directly. You can run many Docker containers, each with its own application, on a single server - and those applications will be isolated from one another, thus providing data security and reliability.Docker 是一个开源平台支持开发人员和系统管理员将应用程序打包为容器。这些容器可以被发布到部署平台 (such as on-premises servers or servers in the cloud)并直接运行。根据需要在一台服务器上可以运行多个 Docker 容器每个容器承载独立的应用且应用之间相互隔离从而保障数据安全和可靠性。on-premises, on-prem本地部署 premise [premɪs] n. 前提假定 v. 假定预述 (条件等)引导 (论述等)提出...作为前提1. Docker architectureDocker uses a client-server architecture.The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface. Another Docker client is Docker Compose, that lets you work with applications consisting of a set of containers.‌镜像 (Images)相当于“安装包”是只读模板包含运行应用所需的代码、库、环境配置用于创建容器。容器 (Containers)相当于“运行中的程序”是镜像的运行实例拥有独立的文件系统、网络和进程空间可快速启动或停止。仓库 (Registries)相当于“应用商店”用于存储和分发镜像最常用的是公共仓库 Docker Hub也支持搭建私有仓库。‌‌1.1. Docker objectsWhen you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects.ImagesAn image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image that is based on the Ubuntu image but includes the Apache web server and your application, as well as the configuration details needed to make your application run.You might create your own images or you might only use those created by others and published in a registry. To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.容器映像是用于供应容器的只读模板。具体而言Docker 守护进程读取容器映像按照映像定义在服务器上创建、配置容器并启动容器内的应用。ContainersA container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.By default, a container is relatively well isolated from other containers and its host machine. You can control how isolated a container’s network, storage, or other underlying subsystems are from other containers or from the host machine.A container is defined by its image as well as any configuration options you provide to it when you create or start it. When a container is removed, any changes to its state that aren’t stored in persistent storage disappear.Containers bundle all the code and dependencies of an application in a standard format, allowing it to run quickly and reliably on most servers. Docker is an industry-standard open source format for containers.容器将应用的全部代码和依赖项打包为标准格式使其能够在大多数服务器上快速、稳定地运行。Docker 是业界标准的开源容器格式。Docker container is a running instance of a Docker image. However, unlike in traditional virtual machines, a Docker container runs on the kernel of the host operating system, so the image contains no separate operating system. While that makes the container lightweight and portable, it also requires the container to be configured for a specific operating system. A Docker container holding an application written and compiled to target Linux can be run only on a Linux-based server; the same is true of an application written and compiled to target Windows.Docker 容器则是 Docker 映像的运行实例。与传统虚拟机不同Docker 容器直接运行在主机操作系统内核之上因此映像本身不包含独立的操作系统。这使得容器轻量且可移植但也要求容器必须针对特定操作系统进行配置。为 Linux 编写并编译的应用容器只能在基于 Linux 的服务器上运行基于 Windows 的应用容器同理。Every Docker container has its own file system, its own network stack and therefore its own IP address, its own process space, and defined resource limitations for CPU and memory. Since a Docker container does not have to boot an operating system, it starts up almost instantly. Docker is about isolation, separating the resources of a host operating system from the application. That’s why it’s possible to run many containers on a single server, each securely separated from each other but sharing the base operating system and hardware.每个 Docker 容器都拥有独立的文件系统、独立的网络体系 (因此拥有独立 IP 地址)、独立的进程空间以及设定好的 CPU 和内存资源限制。同时由于 Docker 容器不需要启动操作系统因此几乎可以瞬间启动。Docker 的核心是隔离将主机操作系统的资源与应用分离开。这就是为什么可以在一台服务器上运行大量容器彼此安全隔离同时共享底层操作系统和硬件资源。1.2. The Docker daemonThe Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.Docker 守护进程是运行在每台用于承载 Docker 容器的服务器、桌面设备或工作站上的后台进程。它负责管理与容器的所有交互操作例如启动、停止容器以及为容器路由进出的网络通信。1.3. The Docker clientThe Docker client (docker) is the primary way that many Docker users interact with Docker. When you use commands such asdocker run, the client sends these commands todockerd, which carries them out. Thedockercommand uses the Docker API. The Docker client can communicate with more than one daemon.Docker 客户端是开发人员和管理员用来与 Docker 守护进程交互的工具。Docker 客户端最初仅提供命令行界面如今已支持图形化界面。1.4. Docker DesktopDocker Desktop is an easy-to-install application for your Mac, Windows, or Linux environment that enables you to build and share containerized applications and microservices. Docker Desktop includes the Docker daemon (dockerd), the Docker client (docker), Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper.1.5. Docker registriesA Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker looks for images on Docker Hub by default. You can even run your own private registry.When you use thedocker pullordocker runcommands, Docker pulls the required images from your configured registry. When you use thedocker pushcommand, Docker pushes your image to your configured registry.2. Docker vs. Virtual MachinesThe difference between traditional virtual machines (VMs) and containers is significant. A VM is a complete software simulation of a server (or of any computer) that includes the operating system, device drivers, applications, and data. In a VM setup, a hypervisor runs on the server and orchestrates the virtual machines, performing the same function that the Docker Engine performs with containers.传统虚拟机 (VMs) 与容器之间的区别非常显著。VM 是对服务器 (或任意计算机) 的完整软件模拟其中包含操作系统、设备驱动程序、应用和数据。在 VM 架构中虚拟机管理程序运行在服务器上负责编排虚拟机其所承担的功能与 Docker Engine 对容器的作用相同。A container, by contrast, holds only applications and data; it uses a host computer operating system and device drivers.相比之下容器只包含应用和数据它直接使用主机的操作系统和设备驱动程序。VMs are used to run multiple operating systems and provide secure, isolated application environments on a single physical machine.VM 用于在单台物理机上运行多个操作系统并提供安全、隔离的应用运行环境。Containers, on the other hand, provide an isolated environment for running applications while sharing the host operating system kernel, eliminating the need for a full OS installation within each container.而容器则在共享主机操作系统内核的同时为应用运行提供隔离环境无需在每个容器内部安装完整操作系统。3. Getting started with ContainersInstall DockerThe first step is to download and install Docker on your preferred operating system. Docker provides installation packages for Windows, macOS, and various Linux distributions, making it accessible to a wide range of users.第一步是在您使用的操作系统上下载并安装 DockerDocker 为 Windows、macOS 及各种 Linux 发行版提供安装包。Create a Docker imageStart by creating a Docker image, which serves as the blueprint for your container. This involves writing a Dockerfile, a text file that defines the steps required to build your image, including the base image, installation of dependencies, and application configuration. A Docker image is built up in layers, each representing one of the steps in the Dockerfile.首先创建一个 Docker 映像它将作为您的容器模板。这需要编写一个 Dockerfile 文本文件在其中定义构建映像所需的步骤包括基础映像、依赖项安装和应用配置。Docker 映像采用分层构建每一层对应 Dockerfile 中的一个步骤。Build and runOnce your Docker image is ready, you can build and run your first container. Docker’s command-line interface provides intuitive commands to manage containers, allowing you to start, stop, and monitor their status.Docker 映像准备就绪后您就可以构建并运行您的第一个容器了。Explore Docker’s ecosystemDocker offers a rich set of tools and services you can use to enhance your containerization experience. Docker Hub, a cloud-based repository, provides a vast collection of ready-to-use images and serves as a platform for sharing and collaborating on Docker-related projects. Docker Compose simplifies multicontainer application management.Docker 提供丰富的工具和服务可进一步提升容器化体验。4. DockerfileThe Dockerfile uses DSL (Domain Specific Language) and contains instructions for generating a Docker image. Dockerfile will define the processes to quickly produce an image. While creating your application, you should create a Dockerfile in order since the Docker daemon runs all of the instructions from top to bottom.Docker image is created using a Dockerfile.References[1] Yongqiang Cheng (程永强), https://yongqiang.blog.csdn.net/