更新时间:2022年12月10日
简介
官网:containerd
Containerd 是工业级的容器运行时,是从 Docker 中分离出来的底层容器运行时。相比较于 Docker,其设计目的主要是为了嵌入到一个更大的系统中(一般嵌入到Kubernetes),而不是直接由开发人员或终端用户使用
组件构成
Containerd 正常使用需要包含以下几个组件:
containerd
:主体程序runc
:容器运行时CNI pulgins
:网络相关插件,提供实现了 CNI 协议的接口
安装方式
Containerd 在 Linux 上安装方式主要有以下两种
- 二进制安装包安装
- 包管理器安装(由 Docker 官方提供支持。目前支持
.deb
和.rpm
,containerd.io
包同时包含runc
,但不包含CNI
插件)
DNF/APT 安装
DNF 安装
安装方法参考
- 清华源安装文档:docker-ce | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
- 官方安装文档:Install Docker Engine on CentOS | Docker Documentation
准备
主机列表
主机名 | 操作系统 | IP |
---|---|---|
contanerd | Rocky Linux release 8.7 (Green Obsidian) | 192.168.111.181 |
清除原有的软件
如果过去安装过 docker 或者 containerd,需要先卸载
$ dnf remove -y docker-ce docker-ce-cli containerd.io
推荐安装的依赖
device-mapper-persistent-data
:Linux 2.6 内核中支持逻辑卷管理的通用设备映射机制(RockyLinux 8 内核为 4.18,可以不安装)lvm2
:逻辑卷管理工具(RockyLinux 8 系统默认有安装)
$ dnf install -y device-mapper-persistent-data lvm2
下载仓库文件(CentOS/RHEL)
$ curl -o /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
替换仓库为国内源
官方源在国内访问速度较慢,可以替换为国内源(此处列举<清华源>和<阿里源>,选一即可)
# 替换软件仓库为 TUNA
$ sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
# 替换软件仓库为 ali
$ sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
更新缓存
$ dnf makecache
安装
**安装最新稳定版本 **
# 安装 containerd.io latest stable(最新稳定)版本
$ dnf install -y containerd.io
安装指定版本
# 查看版本
$ dnf list containerd.io.x86_64 --showduplicates | sort -r
Last metadata expiration check: 0:23:50 ago on Sun 11 Dec 2022 09:21:33 PM EST.
containerd.io.x86_64 1.6.9-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.8-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.7-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.6-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.4-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.12-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.11-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.6.10-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.5.11-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.5.10-3.1.el8 docker-ce-stable
containerd.io.x86_64 1.4.9-3.1.el8 docker-ce-stable
.......
# 安装指定版本 dnf -y install containerd.io-[VERSION].[架构]
$ dnf -y install containerd.io-1.6.12-3.1.el8.x86_64
验证
验证安装的 containerd 版本
$ containerd -v
containerd containerd.io 1.6.12 a05d175400b1145e5e6a735a6710579d181e7fb0
验证安装的 runc 版本
$ runc -v
runc version 1.1.4
commit: v1.1.4-0-g5fd4c4d
spec: 1.0.2-dev
go: go1.18.9
libseccomp: 2.5.2
查看 service 文件
$ cat /usr/lib/systemd/system/containerd.service
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under th