13.3.2.5. 修改 Google Cloud Platform 对象存储桶


注意

目前,IBM Power 和 IBM Z 不支持修改 Google Cloud Platform 对象存储桶。

使用以下步骤为虚拟构建器配置跨原始资源共享(CORS)。

注意

如果没有 CORS 配置,上传构建 Dockerfile 会失败。

步骤

  1. 使用以下引用来创建 JSON 文件,以满足您的特定 CORS 需求。例如:

    $ cat gcp_cors.json

    输出示例

    [
        {
          "origin": ["*"],
          "method": ["GET"],
          "responseHeader": ["Authorization"],
          "maxAgeSeconds": 3600
        },
        {
          "origin": ["*"],
          "method": ["PUT"],
          "responseHeader": [
                  "Content-Type",
                  "x-goog-acl",
                  "origin"],
          "maxAgeSeconds": 3600
        }
    ]

  2. 输入以下命令更新 GCP 存储桶:

    $ gcloud storage buckets update gs://<bucket_name> --cors-file=./gcp_cors.json

    输出示例

    Updating
      Completed 1

  3. 您可以运行以下命令来显示 GCP 存储桶的更新 CORS 配置:

    $ gcloud storage buckets describe gs://<bucket_name>  --format="default(cors)"

    输出示例

    cors:
    - maxAgeSeconds: 3600
      method:
      - GET
      origin:
      - '*'
      responseHeader:
      - Authorization
    - maxAgeSeconds: 3600
      method:
      - PUT
      origin:
      - '*'
      responseHeader:
      - Content-Type
      - x-goog-acl
      - origin

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部