1、官网安装说明

        cintainerd官网地址,参考安装说明文档,有三种安装方式,分别是:二进制文件,apt、源码编译。该文章重点讲解二进制文件安装方式。

2、安装(以安装1.7.20版本为例)

2.1、二进制安装

安装命令

#1、通过wget下载安装包
wget https://github.com/containerd/containerd/releases/download/v1.7.20/containerd-1.7.20-linux-amd64.tar.gz

#2、解压到/usr/local文件夹中
tar Cxzvf /usr/local containerd-1.7.20-linux-amd64.tar.gz

#3、下载containers.service
wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service

#4、复制containers.service到指定位置/usr/local/lib/systemd/system/
cp containerd.service /usr/local/lib/systemd/system/containerd.service

#5、配置启动
systemctl daemon-reload
 
systemctl enable containerd

2.2、apt安装

# Add Docker's official GPG key:

sudo apt-get update

sudo apt-get install ca-certificates curl

sudo install -m 0755 -d /etc/apt/keyrings

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc

sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:

echo \

"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \

$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \

sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install containerd.io

systemctl enable containerd

3、优化配置

#!/bin/sh
 
# 生成 containerd 默认配置文件
containerd config default > /etc/containerd/config.toml

#修改sandbox_image为阿里镜像,方便国内安装
sed -i 's/registry.k8s.io\/pause:/registry.aliyuncs.com\/google_containers\/pause:/g' /etc/containerd/config.toml

 
# 修改容器存放目录
mkdir -p  /data/containerd
sed -i 's/root = "\/var\/lib\/containerd"/root = "\/data\/containerd"/g' /etc/containerd/config.toml

#开启systemd cgroup 驱动(k8s必须要开启,不然出现不能重启等问题)
#vim /etc/containerd/config.toml,找到SystemdCgroup,改为true
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
 
# 重启 containerd
systemctl restart containerd
 

4、安装runc

#!/bin/sh

wget https://github.com/opencontainers/runc/releases/download/v1.1.13/runc.amd64

install -m 755 runc.amd64 /usr/local/sbin/runc

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部