能自己做网站吗,做曖視頻网站,WordPress用户聊天功能,个人博客网站制作图片Docker Containerd概述
Containerd是一个开源的容器运行时#xff0c;它提供了一种标准化的方式来管理容器的生命周期。该项目最初是由Docker开发团队创建的#xff0c;并在后来成为了一个独立的项目#xff0c;被纳入了Cloud Native Computing Foundation#xff08;C…Docker Containerd概述
Containerd是一个开源的容器运行时它提供了一种标准化的方式来管理容器的生命周期。该项目最初是由Docker开发团队创建的并在后来成为了一个独立的项目被纳入了Cloud Native Computing FoundationCNCF的孵化项目中。
Containerd的特点和功能
容器生命周期管理 Containerd管理容器的生命周期包括容器的创建、运行、暂停、恢复、停止和销毁等操作 标准化接口 Containerd提供了一个标准化的容器运行时接口使得它可以与多个容器编排系统和工具集成例如kubernetes、Docker Compose 镜像管理 它支持容器镜像的拉取、推送、保存和加载等操作、Containerd使用OCIOpen Cintainer Initiative规范定义容器镜像的格式 插件体系结构 Containerd具有可扩展插件体系接、运行用户通过插件来扩展其功能例如存储去掉、网络插件等。 跨平台支持 Containerd可以在不同的操作系统上运行从而提供了跨平台的支持。 与kubernetes集成 Contained作为Kubernetes的默认容器运行时与kubernetes紧密集成为容器工作负载的管理提供了良好的支持 安全性 Contained实现了严格的容器隔离和安全性措施确保容器之间的隔离性以及对主机系统的安全性。
Containerd的起源与背景
Containerd 的起源可以追溯到Docker 项目。Docker 最初作为一个开源项目推出旨在简化应用程序的打包、分发和部署过程。Docker引入了容器的概念将应用程序和其依赖项打包到一个容器中使得应用在不同环境中可以一致地运行。随着Docker的发展其架构逐渐变得复杂包含了许多功能如镜像构建、服务编排等。为了更好 地组织和管理这些功能Docker团队决定将Docker 引擎拆分成多个组件其中一个关键的组件就是 Containerd。
Containerd架构概述 Containerd的架构是moduiarity模块化和可扩展的体现它被设计为一个轻量级、高度可定制的容器运行时s 为了解耦Containerd将系统划分为了不同的组件每个组件都由一个或多个模块写作完成Core部分每一种类型的模块都以插件的形式集成到Containerd中 Containerd组件大致分为Storage、Metadata和Runtime这三个主要方面
Docker Containerd安装与使用
安装Containerd
#使用ali镜像仓库
[rootbogon ~]# rm -rf /etc/yum.repos.d/*
[rootbogon ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[rootbogon ~]# curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
# step 1: 安装必要的一些系统工具
[rootbogon ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
[rootbogon ~]# sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3
[rootbogon ~]# sudo sed -i sdownload.docker.commirrors.aliyun.com/docker-ce /etc/yum.repos.d/docker-ce.repo
[rootbogon ~]# yum clean all
#安装Containerd
[rootbogon ~]# yum -y install containerd.io配置Containerd
#生成配置文件
[rootbogon ~]# mkdir -p /etc/containerd #没有该目录创建
#更改默认配置文件
[rootbogon ~]# containerd config default/etc/containerd/config.toml
#配置镜像加速
[rootbogon ~]# vim /etc/containerd/config.toml
#找到[plugins.io.containerd.grpc.v1.cri.registry.mirrors]该行
#添加阿里云镜像源[plugins.io.containerd.grpc.v1.cri.registry.config.docker.io]endpoint [https://registry.cn-hangzhou.aliyuncs.com ,https://registry-1.docker.io]#启动服务
[rootbogon ~]# systemctl enable containerd
[rootbogon ~]# systemctl start containerdContainerd基本操作
镜像类操作
#拉取镜像
[rootbogon ~]# ctr images pull hub.atomgit.com/amd64/nginx:1.25.2-perl
#查看镜像
[rootbogon ~]# ctr images ls
REF TYPE DIGEST SIZE PLATFORMS LABELS
hub.atomgit.com/amd64/nginx:1.25.2-perl application/vnd.docker.distribution.manifest.v2json sha256:615eb6b7237368628ba586460fdab74bccbd4610533f59717ef2cc7c25458efc 78.5 MiB linux/amd64 -
#检测本地镜像
[rootbogon ~]# ctr images check
#重命名
[rootbogon ~]# ctr images tag hub.atomgit.com/amd64/nginx:1.25.2-perl nginx:v1
[rootbogon ~]# ctr images tag hub.atomgit.com/amd64/nginx:1.25.2-perl nginx:v2
#删除镜像
[rootbogon ~]# ctr images tag rm nginx:v2
#镜像挂载到主目录
[rootbogon ~]# ctr images mount nginx:v1 /mnt
[rootbogon ~]# df
ctr images mount nginx:v1 /mnt
#取消镜像挂载
[rootbogon ~]# ctr images unmount /mnt
#镜像导出 格式:ctr images export --all-platforms 文件名 镜像名称[镜像标签]
[rootbogon ~]# ctr images export --all-platforms nginx_v1.tar nginx:v1
#镜像导入 格式:ctr images import 文件名
[rootbogon ~]# ctr imgaes import nginx_v1.tar 容器类操作
#创建容器
[rootbogon ~]# ctr containers create nginx:v1 nginx
#列出容器
[rootbogon ~]# ctr containers ls
#查看容器详细信息
[rootbogon ~]# ctr containers info nginx
#删除容器
[rootbogon ~]# ctr containers rm nginx
[rootbogon ~]# ctr containers ls任务类操作
#启动容器 容器需先存在
[rootbogon ~]# ctr containers create nginx:v1 nginx
[rootbogon ~]# ctr task start -d nginx
-d 放入后台运行
#查看容器
[rootbogon ~]# ctr task ls
#进入容器
[rootbogon ~]# ctr task exec --exec-id 0 -t nginx sh
--exec-id id随意数字但不要重复
#暂停容器
[rootbogon ~]# ctr task pause nginx
[rootbogon ~]# ctr task ls
#恢复容器
[rootbogon ~]# ctr task resume nginx
[rootbogon ~]# ctr task ls
#杀死容器
[rootbogon ~]# ctr task kill nginx
[rootbogon ~]# ctr task ls
#删除任务
[rootbogon ~]# ctr task rm nginx
#但创建容器时也有同名快照即便已经删除可以使用ctr task start -d nginx命令利用已删除的任务启动起来使此容器恢复运行
#删除容器
[rootbogon ~]# ctr task kill nginx
[rootbogon ~]# ctr container rm nginx
#获取容器的内存、CPU和PID的限额与使用量
[rootbogon ~]# ctr containers create nginx:v1 nginx
[rootbogon ~]# ctr task start -d nginx
[rootbogon ~]# ctr task metrics nginx
#查看容器中所有进程在宿主机中的PID
[rootbogon ~]# ctr task ps nginx其他操作
#列出当前所有插件
[rootbogon ~]# ctr plugins ls
#查看命名空间
[rootbogon ~]# ctr ns create test
[rootbogon ~]# ctr ns ls
#创建命名空间
[rootbogon ~]# ctr ns create test
[rootbogon ~]# ctr ns create test01
[rootbogon ~]# ctr ns ls
#删除命名空间
[rootbogon ~]# ctr ns rm test01
#使用命名空间 使用-n 指定命名空间
[rootbogon ~]# ctr -n test
test
[rootbogon ~]# ctr ns create test01
[rootbogon ~]# ctr ns ls
#删除命名空间
[rootbogon ~]# ctr ns rm test01
#使用命名空间 使用-n 指定命名空间
[rootbogon ~]# ctr -n test