安装Containerd
官方说明文档
https://github.com/containerd/containerd/blob/main/docs/getting-started.md
一、下载containerd压缩包
https://github.com/containerd/containerd/releases/tag/v1.6.8
二、解压containerd-1.6.8-linux-amd64.tar.gz
# C 指定解压到XX目录
tar Cxzvf /usr/local containerd-1.6.8-linux-amd64.tar.gz
systemd 如果您打算通过systemd启动容器,您还应该下载
文档给出的地址打不开,下面是github地址
containerd.service地址:https://github.com/containerd/containerd/blob/main/containerd.service
- 下载文件后,放到/usr/local/lib/systemd/system/containerd.service 下
- 执行以下命令
# 如果没有目录就先创建
mkdir -p /usr/local/lib/systemd/system
cd /usr/local/lib/systemd/system
vim containerd.service
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 the License.
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
#uncomment to enable the experimental sbservice (sandboxed) version of containerd/cri integration
#Environment="ENABLE_CRI_SANDBOXES=sandboxed"
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
- 使服务生效
systemctl daemon-reload
systemctl enable --now containerd
三、安装runc
https://github.com/opencontainers/runc/releases
install -m 755 runc.amd64 /usr/local/sbin/runc
查看runc版本
runc -v
四、安装CNI插件
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.1.1.tgz
五、生成containerd配置文件
# 先创建目录
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
六、配置 systemd cgroup 驱动
对于使用systemd作为init system的Linux的发行版,使用systemd作为容器的cgroup driver可以确保服务器节点在资源紧张的情况更加稳定,因此这里配置各个节点上containerd的cgroup driver为systemd
七、修改沙箱镜像地址
vim config.toml
# 快速查询sandbox
# 使用命令行 :/sandbox
# 修改地址为:registry.aliyuncs.com/google_containers/pause:3.7
八、重启containerd
systemctl restart containerd
九、检查安装是否成功
ctr version
本文来自博客园,作者:弩哥++,转载请注明原文链接:https://www.cnblogs.com/bangbangzoutianya/p/16805788.html