[转帖]containerd_v1.6.0+nerdctl+buildkit 二进制安装,支持多CPU并发构建

containerd,v1,nerdctl,buildkit,二进制,安装,支持,cpu,并发,构建 · 浏览次数 : 0

小编点评

**Docker manifest list:** ``` config_path = "" endpoint = https://registry-1.docker.io endpoint = https://harbor.kids.com ca_file = /home/data/cert/ca.pem cert_file = /home/data/cert/harbor.pem key_file = /home/data/cert/harbor-key.pem ``` **Instructions for using the docker manifest:** 1. Add the necessary credentials to the `config_path` variable in the manifest. 2. Run the following command to pull the image: ``` docker pull harbor.cadp.com/smartgate/gwit:v5 --insecure-registry ``` 3. Push the image to a container registry: ``` docker push harbor.cadp.com/public/elasticsearch:7.13.1 --insecure-registry https://kubernetes-release.pek3b.qingstor.com/containerd/containerd/releases/download/v1.6.4/containerd-1.6.4-linux-amd64.tar.gz ```

正文

一、安装containerd

# yum install  libseccomp -y

#下载containerd
curl -L https://github.com/containerd/containerd/releases/download/v1.6.0/cri-containerd-cni-1.6.0-linux-amd64.tar.gz -O cri-containerd-cni-1.6.0-linux-amd64.tar.gz

#解压containerd到根目录
tar zxvf cri-containerd-cni-1.6.0-linux-amd64.tar.gz -C /

#生成containerd配置
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml

#启动containerd
systemctl daemon-reload
systemctl enable containerd
systemctl start containerd
systemctl status containerd

#把cni命令ln到/usr/local/bin目录下
#ln -s /opt/cni/bin/* /usr/local/bin

curl -L https://github.com/opencontainers/runc/releases/download/v1.1.0/runc.amd64 -o /usr/local/sbin/runc

chmod +x /usr/local/sbin/runc

    二、安装nerdctl

    #下载nerdctl
    curl -L https://github.com/containerd/nerdctl/releases/download/v0.18.0/nerdctl-0.18.0-linux-amd64.tar.gz -O nerdctl-0.18.0-linux-amd64.tar.gz
    

    tar zxvf nerdctl-0.18.0-linux-amd64.tar.gz -C /usr/local/sbin

    echo "alias docker='nerdctl --namespace k8s.io'" >> /etc/profile
    echo "alias docker-compose='nerdctl compose'" >> /etc/profile
    source /etc/profile

    #配置nerdctl
    mkdir -p /etc/nerdctl/
    cat > /etc/nerdctl/nerdctl.toml << 'EOF'
    namespace = "k8s.io"
    insecure_registry = true
    cni_path = "/data/kube/bin"
    EOF

      三、安装buildkit

      #下载buildkit
      curl -L https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-amd64.tar.gz -o buildkit-v0.9.3.linux-amd64.tar.gz
      

      tar zxvf buildkit-v0.9.3.linux-amd64.tar.gz -C /usr/local/

      #/etc/buildkit/buildkitd.toml为buildkitd默认配置

      mkdir -p /etc/buildkit/
      cat > /etc/buildkit/buildkitd.toml << 'EOF'

      debug = true

      root is where all buildkit state is stored.

      root = "/var/lib/buildkit"

      insecure-entitlements allows insecure entitlements, disabled by default.

      insecure-entitlements = [ "network.host", "security.insecure" ]

      [worker.oci]
      enabled = true
      platforms = [ "linux/amd64", "linux/arm64" ]
      snapshotter = "auto"
      rootless = false
      noProcessSandbox = false
      gc = true
      gckeepstorage = 9000
      max-parallelism = 4

      [[worker.oci.gcpolicy]]
      keepBytes = 512000000
      keepDuration = 172800
      filters = [ "typesource.local", "typeexec.cachemount", "type==source.git.checkout"]

      [registry."19.15.14.158:31104"]
      mirrors = ["19.15.14.158:31104"]
      http = true #使用http协议
      insecure = true #不验证安全证书
      [registry."mmzwwwdocker.xxxxxx.com:31104"]
      mirrors = ["mmzwwwdocker.xxxxxxx.com:31104"]
      http = true #使用http协议
      insecure = true #不验证安全证书
      EOF

      cat > /etc/systemd/system/buildkit.service << 'EOF'
      [Unit]
      Description=BuildKit
      Documentation=https://github.com/moby/buildkit

      [Service]
      ExecStart=/usr/local/bin/buildkitd --oci-worker=false --containerd-worker=true

      [Install]
      WantedBy=multi-user.target
      EOF

      systemctl daemon-reload
      systemctl enable buildkit
      systemctl start buildkit
      systemctl status buildkit

        四、测试

        mkdir test
        cd test
        cat > Dockerfile << 'EOF'
        FROM alpine
        EOF
        

        docker build --platform arm64,amd64 -t test1 .

        [+] Building 4.6s (7/7) FINISHED
        => [internal] load build definition from Dockerfile 0.0s
        => => transferring dockerfile: 49B 0.0s
        => [internal] load .dockerignore 0.0s
        => => transferring context: 2B 0.0s
        => [linux/amd64 internal] load metadata for docker.io/library/alpine:latest 0.6s
        => [linux/arm64 internal] load metadata for docker.io/library/alpine:latest 2.6s
        => CACHED [linux/amd64 1/1] FROM docker.io/library/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300 0.0s
        => => resolve docker.io/library/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300 0.0s
        => [linux/arm64 1/1] FROM docker.io/library/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300 1.7s
        => => resolve docker.io/library/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300 0.0s
        => => sha256:9b3977197b4f2147bdd31e1271f811319dcd5c2fc595f14e81f5351ab6275b99 2.10MB / 2.72MB 1.9s
        => exporting to oci image format 1.9s
        => => exporting layers 0.0s
        => => exporting manifest sha256:1bfa860f8991c3b6952fbb59493e8c346c4e46a78fff4099b4d95d87ad741283 0.0s
        => => exporting config sha256:69d06718b798aebf8c13b1a53299d1f791f8118dcd0fa9a0a827bf2f595aa9ca 0.0s
        => => exporting manifest sha256:e3b23b57855e132673409165a5a6559180c32d273399f13cf078163fea7398a0 0.0s
        => => exporting config sha256:35e223a20dbce8c0b81d3257f8cad0c7b2b35d8e18eadfec7eeb7de86a472e7b 0.0s
        => => exporting manifest list sha256:631ae1b627eb47a92dbaa80d1f2f4d38bd0b2b9196736076053e02689a27101c 0.0s
        => => sending tarball 0.1s
        unpacking docker.io/library/test1:latest (sha256:631ae1b627eb47a92dbaa80d1f2f4d38bd0b2b9196736076053e02689a27101c)...done

          在这里插入图片描述

          测试动行时

          docker  run -d -p 80:80 nginx
          

            在这里插入图片描述

            iptables -t nat -nvL
            

              在这里插入图片描述

              五、配置私有仓库
              vim /etc/containerd/config.toml

                  [plugins."io.containerd.grpc.v1.cri".registry]
                    config_path = ""
              
                <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.auths<span class="token punctuation">]</span>
                  <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.auths.<span class="token string">"harbor.kids.com"</span><span class="token punctuation">]</span>
                    username <span class="token operator">=</span> <span class="token string">"admin"</span>
                    password <span class="token operator">=</span> <span class="token string">"Harbor123456"</span>
              
                <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.configs<span class="token punctuation">]</span>
              
                  <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.configs.<span class="token string">"harbor.kids.com"</span>.tls<span class="token punctuation">]</span>
                    insecure_skip_verify <span class="token operator">=</span> <span class="token boolean">true</span>
              
                <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.headers<span class="token punctuation">]</span>
              
                <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.mirrors<span class="token punctuation">]</span>
              
                  <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.mirrors.<span class="token string">"docker.io"</span><span class="token punctuation">]</span>
                     endpoint <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"https://registry-1.docker.io"</span><span class="token punctuation">]</span>
              
                  <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.mirrors.<span class="token string">"harbor.kids.com"</span><span class="token punctuation">]</span>
                     endpoint <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"https://harbor.kids.com"</span><span class="token punctuation">]</span>       <span class="token comment">#如果是http时,改为http</span>
              
                <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.tlss<span class="token punctuation">]</span>
              
                  <span class="token punctuation">[</span>plugins.<span class="token string">"io.containerd.grpc.v1.cri"</span>.registry.tlss.<span class="token string">"harbor.kids.com"</span><span class="token punctuation">]</span>
                    ca_file <span class="token operator">=</span> <span class="token string">"/home/data/cert/ca.pem"</span>
                    cert_file <span class="token operator">=</span> <span class="token string">"/home/data/cert/harbor.pem"</span>
                    key_file <span class="token operator">=</span> <span class="token string">"/home/data/cert/harbor-key.pem"</span>
              

                六、nerdctl 使用http 的harbor

                nerdctl login harbor.cadp.com --insecure-registry -u admin -p Harbor123456
                

                WARN[0000] WARNING! Using --password via the CLI is insecure. Use --password-stdin.
                WARN[0000] skipping verifying HTTPS certs for "harbor.cadp.com"
                WARNING: Your password will be stored unencrypted in /root/.docker/config.json.
                Configure a credential helper to remove this warning. See
                https://docs.docker.com/engine/reference/commandline/login/#credentials-store

                Login Succeeded

                  #拉取镜像

                  docker pull harbor.cadp.com/smartgate/gwit:v5 --insecure-registry
                  

                  #这个为ctr 下载镜像命令
                  ctr -n k8s.io i pull --plain-http harbor.cadp.com/smartgate/gwit:v5
                  # --plain-http 表示使用http下载

                    #推送镜像

                    docker push harbor.cadp.com/public/elasticsearch:7.13.1 --insecure-registry
                    

                      https://kubernetes-release.pek3b.qingstor.com/containerd/containerd/releases/download/v1.6.4/containerd-1.6.4-linux-amd64.tar.gz

                      • nerdctl docker ctr命令在这里插入图片描述

                      与[转帖]containerd_v1.6.0+nerdctl+buildkit 二进制安装,支持多CPU并发构建相似的内容:

                      [转帖]containerd_v1.6.0+nerdctl+buildkit 二进制安装,支持多CPU并发构建

                      一、安装containerd # yum install libseccomp -y #下载containerd curl -L https://github.com/containerd/containerd/releases/download/v1.6.0/cri-containerd-cni-

                      [转帖]containerd_v1.6.0+nerdctl+buildkit 二进制安装,支持多CPU并发构建

                      一、安装containerd # yum install libseccomp -y #下载containerd curl -L https://github.com/containerd/containerd/releases/download/v1.6.0/cri-containerd-cni-

                      [转帖]containerd命令操作

                      一、版本信息 内核版本:5.19.12-1.el7.elrepo.x86_64 系统版本:CentOS Linux release 7.9.2009 二、下载文件: wget https://github.com/opencontainers/runc/releases/download/v1.1.

                      [转帖]Containerd安装与使用

                      https://www.cnblogs.com/punchlinux/p/16496094.html Containerd 的技术方向和目标 简洁的基于 gRPC 的 API 和 client library 完整的 OCI 支持(runtime 和 image spec) 同时具备稳定性和高性能的

                      [转帖]k3s containerd和docker 命令对比

                      https://www.cnblogs.com/already/p/12691327.html k3s默认使用container 两者命令对比表: idcontainerd 命令docker 命令备注 1 ctr image ls docker images 获取image信息 2 ctr imag

                      [转帖]k8s containerd私有仓库配置及常用命令

                      containerd相关 一、修改containerd配置文件,添加私有仓库配置 查看containerd的默认配置 containerd config default k3s集群配置文件位置: /etc/rancher/k3s/registries.yaml /var/lib/rancher/k3

                      [转帖]k8s学习-containerd命令行工具crictl使用

                      在最新k8s的版本中,containerdruntime已经不在使用docker,而是使用containerd了。​containerd是什么?containerd的自我介绍中说它是一个开放、可靠的容器运行时,实际上它包含了单机运行一个容器运行时的功能。 containerd为了支持多种OCI Ru

                      [转帖]Centos下使用containerd管理容器:5分钟从docker转型到containerd

                      https://www.cnblogs.com/renshengdezheli/p/16684175.html 目录 一.系统环境 二.前言 三.containerd 四.部署containerd 4.1 安装containerd 4.2 containerd配置文件 4.3 配置container

                      [转帖]k8s系列-06-containerd的基本操作

                      https://www.jianshu.com/p/52a2884594f5 上一篇我们介绍了containerd的安装,本篇我们来简单介绍下如何进行使用。 环境 linux服务器 前置安装 躺过的坑,需要安装下面内容,否则执行ctr run的时候会报错如下: ctr: failed to crea

                      [转帖]用buildkit和containerd构建镜像

                      https://zhuanlan.zhihu.com/p/366671300 最近因为K8s抛弃Docker了,所以就只装了个containerd,这样就需要一个单独的镜像构建工具了,就用了buildkit,这也是Docker公司扶持的,他们公司的人出来搞的开源工具,官网在 https://gith