containerd:配置https私有镜像仓库的最新方法

随着containerd应用越来越广泛,我们必须紧跟官网的节奏。

之前配置https私有镜像仓库的方法比较繁琐,并且不易梳理,下边介绍一下目前最新的配置方法。

配置https私有镜像仓库

我假设你现在已经有私有仓库并且是https

再假设你的harbor域名是harbor.example.cn

你只需要在/etc/containerd/config.toml中配置一下证书的路径:

bash 复制代码
...
    [plugins."io.containerd.grpc.v1.cri".registry]
      config_path = "/etc/containerd/certs.d"
...

然后创建对应的目录及文件

bash 复制代码
mkdir -p /etc/containerd/certs.d/harbor.example.cn

cat > hosts.toml << EOF
server = "https://harbor.example.cn"

[host."https://harbor.example.cn"]
  capabilities = ["pull", "resolve", "push"]
  skip_verify = true
EOF

skip_verify = true 表示跳过TLS的验证,如果想要更安全一些就将它修改为false,上传证书并指定路径

bash 复制代码
[root@anilis-k8s-03 harbor.example.cn]# ls
ca.crt  harbor.example.cn.crt  harbor.example.cn.key

修改配置:

bash 复制代码
cat > hosts.toml << EOF
server = "https://harbor.example.cn"

[host."https://harbor.example.cn"]
  capabilities = ["pull", "resolve", "push"]
  skip_verify = false
  ca = "ca.crt"
EOF

最后重启containerd

bash 复制代码
systemctl restart containerd.service

再次拉取镜像,都可以正常访问了!

如果你还有其他域名需要加,那就创建对应的目录就可以了!

参考官网

containerd:
https://github.com/containerd/containerd/blob/main/docs/cri/config.md
https://github.com/containerd/containerd/blob/main/docs/hosts.md

harbor自签证书:
https://goharbor.io/docs/2.11.0/install-config/configure-https/

相关推荐
Yuanymoon23 天前
【由技及道】镜像星门开启:Harbor镜像推送的量子跃迁艺术【人工智障AI2077的开发日志010】
java·docker·jenkins·harbor·devops
Yuanymoon1 个月前
【由技及道】镜像圣殿建造指南:Harbor私有仓库的量子封装艺术【人工智障AI2077的开发日志009】
java·docker·jenkins·harbor·wsl·devops·gitea
深情不及里子1 个月前
纯手工搭建整套CI/CD流水线指南
ci/cd·gitlab·jenkins·harbor
无区新手1 个月前
Docker+DockerCompose+Harbor安装
docker·docker-compose·harbor
Sundayday472 个月前
5、pod 详解 (kubernetes)
云原生·容器·kubernetes·harbor
老糊涂Lion3 个月前
向harbor中上传镜像(向harbor上传image)
linux·docker·containerd·harbor
风尘浪子3 个月前
DevOps 企业级 CI/CD 实战 —— 整合 GitLab+Jenkins+Harbor+Docker 实现代码全自动化流程管理
ci/cd·docker·pipeline·gitlab·jenkins·harbor·devops·sshpublish
gs801403 个月前
替换 Docker.io 的 Harbor 安全部署指南:域名与 IP 双支持的镜像管理解决方案
docker·harbor