首页 新闻 会员 周边

containerd 使用 docker 镜像加速器的问题

0
悬赏园豆:30 [已解决问题] 解决于 2022-08-21 15:56

在 /etc/containerd/config.toml 中按下面的方式添加镜像加速器

[plugins]
    [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://xxxxxx.mirror.aliyuncs.com"]

pull image 时没有走镜像加速器

# nerdctl pull docker.io/daprio/daprd:1.8.3
INFO[0011] trying next host                              error="failed to authorize: failed to fetch anonymous token: Get \"https://auth.docker.io/token?scope=repository%3Adaprio%2Fdaprd%3Apull&service=registry.docker.io\": net/http: TLS handshake timeout" host=registry-1.docker.io

请问如何解决这个问题?

dudu的主页 dudu | 高人七级 | 园豆:30925
提问于:2022-08-12 16:49
< >
分享
最佳答案
0

上面的配置方式是旧版 conainterd 采用的,已经 deprecated,改用新版配置方法解决了

  • /etc/containerd/config.toml 中, 在 [plugins."io.containerd.grpc.v1.cri".registry] 下面添加 config_path
    [plugins."io.containerd.grpc.v1.cri".registry]
      config_path = "/etc/containerd/certs.d"
  • 创建文件夹 /etc/containerd/certs.d/docker.io/,在其中添加包含下面内容的 hosts.toml 文件
[host."https://xxxxxx.mirror.aliyuncs.com"]
  capabilities = ["pull"]
  • 重启 containerd 使配置生效
systemctl restart containerd
dudu | 高人七级 |园豆:30925 | 2022-08-12 17:57
其他回答(1)
0

https://microk8s.io/docs/registry-private

Configure registry mirrors
Under specific circumstances (e.g. geographical restrictions, network firewalls), certain image registries may not be available. For example, for Chinese mainland users k8s.gcr.io is not available, and a mirror such as registry.cn-hangzhou.aliyuncs.com/google_containers can be used instead.

In order to configure a registry mirror for registry.k8s.io and have it point to registry.cn-hangzhou.aliyuncs.com/google_containers, the following configuration is required:

create a directory with the registry name

sudo mkdir -p /var/snap/microk8s/current/args/certs.d/registry.k8s.io

create the hosts.toml file pointing to the mirror

echo '
server = "registry.k8s.io"

[host."https://registry.aliyuncs.com/v2/google_containers"]
capabilities = ["pull", "resolve"]
override_path = true
' | sudo tee -a /var/snap/microk8s/current/args/certs.d/registry.k8s.io/hosts.toml
A restart of the containerd daemon helps but is not required, since changes should take effect immediately.

sudo snap restart microk8s

@earth | 园豆:202 (菜鸟二级) | 2023-08-16 20:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册