Containerd安装

安装containerd

在gitub发布业获取最新下载地址 https://github.com/containerd/containerd/releases

根据系统版本下载对应的tar包。这里提供文章发部时的最新AMD64版本下载地址: containerd-1.7.9-linux-amd64.tar.gz

wget https://github.com/containerd/containerd/releases/download/v1.7.9/containerd-1.7.9-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.9-linux-amd64.tar.gz

下载service文件,以用systemd管理

wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service
cp containerd.service /usr/local/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 the License.

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
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

# 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

安装runc

在gitub发布业获取最新下载地址 https://github.com/containerd/containerd/releases

根据系统版本下载对应的tar包。这里提供文章发部时的最新AMD64版本下载地址: runc.amd64

wget https://github.com/opencontainers/runc/releases/download/v1.1.10/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc

安装cni

在gitub发布业获取最新下载地址 https://github.com/containernetworking/plugins/releases

根据系统版本下载对应的tar包。这里提供文章发部时的最新AMD64版本下载地址: cni-plugins-linux-amd64-v1.3.0.tgz

wget https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.1.1.tgz

编辑配置文件

vim /etc/cni/net.d/10-containerd-net.conflist

{
  "cniVersion": "1.0.0",
  "name": "containerd-net",
  "plugins": [
    {
      "type": "bridge",
      "bridge": "cni0",
      "isGateway": true,
      "ipMasq": true,
      "promiscMode": true,
      "ipam": {
        "type": "host-local",
        "ranges": [
          [{
            "subnet": "10.88.0.0/16"
          }],
          [{
            "subnet": "2001:4860:4860::/64"
          }]
        ],
        "routes": [
          { "dst": "0.0.0.0/0" },
          { "dst": "::/0" }
        ]
      }
    },
    {
      "type": "portmap",
      "capabilities": {"portMappings": true}
    }
  ]
}

运行

ctr images pull docker.io/library/redis:alpine
ctr run docker.io/library/redis:alpine redis