containerd 不能像docker一样 docker login harbor.example.com 登录到镜像仓库,无法从harbor拉取到镜像,需要在每个node节点进行如下配置:

可以通过更改containerd 的config.toml文件添加仓库地址, /etc/containerd/config.toml,如果此文件不存在,可以通过命令生成配置文件

containerd config default> /etc/containerd/config.toml 

在registry处添加如下内容:

[plugins."io.containerd.grpc.v1.cri".registry]
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
          endpoint = ["https://registry-1.docker.io"]  #此行以上为默认配置
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."local.harbor.com"]
          endpoint = ["http://local.harbor.com"]
      [plugins."io.containerd.grpc.v1.cri".registry.configs]
        [plugins."io.containerd.grpc.v1.cri".registry.configs."local.harbor.com".tls]
          insecure_skip_verify = true
        [plugins."io.containerd.grpc.v1.cri".registry.configs."local.harbor.com".auth]
          username = "admin"
          password = "Harbor12345"

修改完之后重启containerd服务

systemctl restart containerd

使用cerdctl命令进行仓库登录测试

 nerdctl --insecure-registry login -u admin local.harbor.com

containerd配置harbor私有仓库_containerd

登陆失败,原因未知

使用crictl进行镜像拉取成功

crictl pull local.harbor.com/library/nginx:1.21.1

containerd配置harbor私有仓库_containerd_02