【Docker】基本概念和底层技术

Docker

Alt

1 什么是 Docker

Docker 是一种容器技术。只要开发者将其应用和依赖包进行打包,放入到一个轻量级的、可移植的容器中,就能发布到任何流行的 linux 机器上。

Docker 的要素:

  • image 镜像:静态的
  • container 容器:动态的;镜像相当于类,容器相当于实例
  • dockerfile 自动化脚本:dockerfile 文件用于创建新的镜像

Docker 的特点:

  • 模拟完全相同的系统环境,解决软件跨环境迁移的问题
  • 完全使用沙箱机制,容器之间相互隔离
  • 容器性能开销极低,比虚拟机更加轻量

Docker 本身并不是容器,而是创建容器的工具,是应用容器引擎。除了 Docker,还有其它工具可以用于创建容器。

Docker 产品类型:

  • CE 社区版
  • EE 企业版

vscode 添加 docker 扩展。



2 Docker 的架构

在这里插入图片描述
Docker 采用的是 C/S 架构。

Docker 对象:

  • 镜像 images:是一个特殊的、分层的文件系统
    • 包含所需的程序、库、资源、配置文件、配置参数等
    • 不包含动态数据,其内容在构建后不再改变
  • 容器 containers:实质是进程
    • docker run 起来以后会添加一个读写层
    • 镜像和容器的关系就是类和实例的关系
  • 仓库 registry:用于保存所有创建好的镜像
    • 公用仓库 Public Registry 是 Docker Hub
    • 私有仓库 Private Registry

启动容器时,Docker daemon 会首先从本地获取相关镜像。当本地镜像不存在时,将从 Regitry 中下载该镜像并保存在本地。拉取镜像必须使用 HTTPS 协议。



3 Docker 的底层技术

3.1 namespace

Docker uses a technology called namespaces to provide the isolated workspace called the container. When you run a container, Docker creates a set of namespaces for that container.

These namespaces provide a layer of isolation. Each aspect of a container runs in a separate namespace and its access is limited to that namespace.

docker engine uses namespaces such as the following on Linux:

  • The pid namespace: Process isolation (PID: Process ID).
  • The net namespace: Managing network interfaces (NET: Networking).
  • The ipc namespace: Managing access to IPC resources (IPC: InterProcess Communication).
  • The mnt namespace: Managing filesystem mount points (MNT: Mount).
  • The uts namespace: Isolationg kernel and version identifiers (UTS: Unix Timesharing System).
  • 进程 PID:实现进程之间的隔离
  • 网络 NET:管理网络接口
  • 进程间通信 IPC:信号量、消息队列和共享内存
  • 挂载 MNT:管理文件系统的挂载点
  • Unix 分时系统 UTS:隔离内核和版本标识

3.2 Control groups

在这里插入图片描述

3.3 联合文件系统

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_64140451/article/details/131859614