docker - Kubernetes 在执行 docker pull 时忽略 config.json
问题描述
我正在尝试从私有注册表中提取图像,并且我将身份验证存储在 kubernetes 集群节点的 /root/.docker/config.json 中。我还验证了在拉取 docker 映像时身份验证是否按预期工作。
curl -v \
-X GET \
-H "Authorization: Bearer $(cat /tmp/auth_bearer.txt)" repo-url/manifests/latest \
-H "Accept: application/vnd.docker.distribution.manifest.v2+json"
回复:
< HTTP/1.1 200 OK < Date: Wed, 11 Mar 2020 23:27:09 GMT <
Content-Type: application/vnd.docker.distribution.manifest.v2+json <
Content-Length: 3455 < Connection: keep-alive < Vary: Origin <
opc-request-id: 772f679098749bb474d59161 < Docker-Content-Digest:
sha256:17dcbbf7c670d8894ddfefc2907c9f045bfc45e60954525635632abbf02910
< { "schemaVersion": 2, "mediaType":
"application/vnd.docker.distribution.manifest.v2+json", "config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 9504,
"digest": "sha256:d59db4a22d6ba8f1d3b5d7c8f8f410688dee569a947bf242e6c3e3b708f634829"
}, "layers": [
{ [...]
从上面的回复中,很明显我在私人仓库位置有图像,并且身份验证是正确的。但是,当我尝试这样做时docker pull <repo-url>/image-name:image-tag
,会出现此错误:
Trying to pull repository <repo-url>/image-name:image-tag ...
pull access denied for <repo-url>/image-name:image-tag, repository does not exist or may require 'docker login'
有人可以告诉我我在这里缺少什么吗?为什么节点忽略存储在 /root/.docker/config.json 中的 docker 凭据?
解决方案
使用基于文件的配置
您可以在此处列出的文件中设置 docker 机密:
{--root-dir:-/var/lib/kubelet}/config.json
{cwd of kubelet}/config.json
${HOME}/.docker/config.json
/.docker/config.json
{--root-dir:-/var/lib/kubelet}/.dockercfg
{cwd of kubelet}/.dockercfg
${HOME}/.dockercfg
/.dockercfg
注意:您可能必须在 kubelet 的环境文件中显式设置 HOME=/root。
推荐阅读
- python - Python中的返回问题
- c# - C#:如何操作列表中项目的值
- javascript - 构造函数是否总是可以立即访问其类中声明的函数?
- java - Java 抑制所有控制台输出
- mysql - 如何解决无法连接到任何指定的MySQL?
- android - 如何在 Agora 中像接听电话一样务实地视频呼叫另一个人,拒绝呼叫与 Android 中的 Whats 应用程序相同?
- javascript - 在浏览器窗口未聚焦时运行函数
- javascript - Fengyuanchen Datapicker - 箭头 prev/next
- python - 如何从文本文件中提取值?
- php - 已上传空文件