3.2. 配置允许对容器镜像进行镜像的凭证


创建容器镜像 registry 凭证文件,以便您可以将红帽的镜像镜像到您的镜像。在安装主机上完成以下步骤。

先决条件

  • 您已将镜像 registry 配置为在断开连接的环境中使用。

流程

  1. 从 Red Hat OpenShift Cluster Manager 下载 registry.redhat.io pull secret
  2. 运行以下命令,以 JSON 格式生成 pull secret 副本:

    $ cat ./pull-secret | jq . > <path>/<pull_secret_file_in_json>
    Copy to Clipboard Toggle word wrap

    指定将 pull secret 存储在 中的目录的路径,以及您创建的 JSON 文件的名称。

    pull secret 示例

    {
      "auths": {
        "cloud.openshift.com": {
          "auth": "b3BlbnNo...",
          "email": "you@example.com"
        },
        "quay.io": {
          "auth": "b3BlbnNo...",
          "email": "you@example.com"
        },
        "registry.connect.redhat.com": {
          "auth": "NTE3Njg5Nj...",
          "email": "you@example.com"
        },
        "registry.redhat.io": {
          "auth": "NTE3Njg5Nj...",
          "email": "you@example.com"
        }
      }
    }
    Copy to Clipboard Toggle word wrap

  3. 运行以下命令,为您的镜像 registry 生成 base64 编码的用户名和密码或令牌:

    $ echo -n '<user_name>:<password>' | base64 -w0
    Copy to Clipboard Toggle word wrap

    通过 <user_name><password> 指定 registry 的用户名和密码。

    输出示例

    BGVtbYk3ZHAtqXs=
    Copy to Clipboard Toggle word wrap

  4. 编辑 JSON 文件并添加描述 registry 的部分:

      "auths": {
        "<mirror_registry>": {
          "auth": "<credentials>",
          "email": "you@example.com"
        }
      },
    Copy to Clipboard Toggle word wrap
    • 对于 <mirror_registry > 值,请指定 registry 域名,以及您的镜像 registry 用来提供内容的可选端口。例如: registry.example.comregistry.example.com:8443
    • 对于 & lt;credentials > 值,请指定镜像 registry 的 base64 编码用户名和密码。

      修改的 pull secret 示例

      {
        "auths": {
          "registry.example.com": {
            "auth": "BGVtbYk3ZHAtqXs=",
            "email": "you@example.com"
          },
          "cloud.openshift.com": {
            "auth": "b3BlbnNo...",
            "email": "you@example.com"
          },
          "quay.io": {
            "auth": "b3BlbnNo...",
            "email": "you@example.com"
          },
          "registry.connect.redhat.com": {
            "auth": "NTE3Njg5Nj...",
            "email": "you@example.com"
          },
          "registry.redhat.io": {
            "auth": "NTE3Njg5Nj...",
            "email": "you@example.com"
          }
        }
      }
      Copy to Clipboard Toggle word wrap

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat