From 2c6a411fde37eb4baa0546ed37a7ef4067ebd3a4 Mon Sep 17 00:00:00 2001 From: halfC <1524398873@qq.com> Date: Sun, 28 Nov 2021 20:23:21 +0800 Subject: [PATCH] [zh] typo Update images.md (#30545) * Update images.md typo * sync en docs * [zh] translate images.md [zh] translate interpretation of config.json images.md * [zh] modify the wording in images.md * [zh] remove origin english in images.md * [zh] del extra # in images.md * [zh] del origin english in images.md --- content/zh/docs/concepts/containers/images.md | 112 +++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/content/zh/docs/concepts/containers/images.md b/content/zh/docs/concepts/containers/images.md index 1360faab32..b782d01833 100644 --- a/content/zh/docs/concepts/containers/images.md +++ b/content/zh/docs/concepts/containers/images.md @@ -68,7 +68,7 @@ There are additional rules about where you can place the separator characters (`_`, `-`, and `.`) inside an image tag. If you don't specify a tag, Kubernetes assumes you mean the tag `latest`. --> -镜像标签可以包含小写字母、大写字符、数字、下划线(`_`)、句点(`.`)和连字符(`-`)。 +镜像标签可以包含小写字母、大写字母、数字、下划线(`_`)、句点(`.`)和连字符(`-`)。 关于在镜像标签中何处可以使用分隔字符(`_`、`-` 和 `.`)还有一些额外的规则。 如果你不指定标签,Kubernetes 认为你想使用标签 `latest`。 @@ -517,6 +517,116 @@ registry keys are added to the `.docker/config.json`. 在 `.docker/config.json` 中配置了私有仓库密钥后,所有 Pod 都将能读取私有仓库中的镜像。 + +### config.json 说明 {#config-json} + + +对于 `config.json` 的解释在原始 Docker 实现和 Kubernetes 的解释之间有所不同。 +在 Docker 中,`auths` 键只能指定根 URL ,而 Kubernetes 允许 glob URLs 以及 +前缀匹配的路径。这意味着,像这样的 `config.json` 是有效的: +```json +{ + "auths": { + "*my-registry.io/images": { + "auth": "…" + } + } +} +``` + + +使用以下语法匹配根 URL (`*my-registry.io`): +``` +pattern: + { term } + +term: + '*' 匹配任何无分隔符字符序列 + '?' 匹配任意单个非分隔符 + '[' [ '^' ] 字符范围 + 字符集(必须非空) + c 匹配字符 c (c 不为 '*','?','\\','[') + '\\' c 匹配字符 c + +字符范围: + c 匹配字符 c (c 不为 '\\','?','-',']') + '\\' c 匹配字符 c + lo '-' hi 匹配字符范围在 lo 到 hi 之间字符 +``` + + +现在镜像拉取操作会将每种有效模式的凭据都传递给 CRI 容器运行时。例如下面的容器镜像名称会匹配成功: + +- `my-registry.io/images` +- `my-registry.io/images/my-image` +- `my-registry.io/images/another-image` +- `sub.my-registry.io/images/my-image` +- `a.sub.my-registry.io/images/my-image` + + +kubelet 为每个找到的凭证的镜像按顺序拉取。 这意味着在 `config.json` 中可能有多项: + +```json +{ + "auths": { + "my-registry.io/images": { + "auth": "…" + }, + "my-registry.io/images/subpath": { + "auth": "…" + } + } +} +``` + + +如果一个容器指定了要拉取的镜像 `my-registry.io/images/subpath/my-image`, +并且其中一个失败,kubelet 将尝试从另一个身份验证源下载镜像。 +