【问题标题】:Push Docker images to Google Container Registry using fabric8-maven-plugin?使用 fabric8-maven-plugin 将 Docker 映像推送到 Google Container Registry?
【发布时间】:2018-04-22 13:20:17
【问题描述】:

我正在使用fabric8-maven-plugin 在运行于 Google Cloud Platform 上的 Jenkins 上构建 Docker 映像。

该插件提供了将图像推送到 Docker 注册表的功能,但我无法使其与 Google Container Registry 一起使用,因为它无法进行身份验证。

通过我的 Jenkins 管道,我可以使用 GCloudBuildWrappergcloud docker -- push 访问注册表。

为了访问 Docker 注册表,fabric8 Maven 插件可以与凭证或 extended authentication 一起使用,但目前这似乎仅适用于 AWS。

那么是否可以使用 fabric8 Maven 插件将 Docker 镜像推送到 Google Container Registry?

【问题讨论】:

    标签: maven google-cloud-platform fabric8


    【解决方案1】:

    找到了我的问题in the docs for Google Container Registry 的解决方案。该页面提供了 2 种方法:Docker 凭证助手,很遗憾我无法开始工作,以及 using an access token

    使用访问令牌方法,您使用“oauth2accesstoken”作为 GCR 的用户名,并使用 gcloud auth application-default print-access-token 作为密码生成令牌。不是很漂亮,但很管用。

    【讨论】:

    • 嗨 Otto,您能提供一些解决方案的代码吗?我遇到了同样的问题
    【解决方案2】:

    基于 otto 的解决方案:

    你需要指定,在~/.m2/settings.xml:

    <server>
      <id>gcr.io/<!--your-registry--></id>
      <username>oauth2accesstoken</username>
      <password><!-- gcloud oauth token goes here --></password>
    </server>
    

    然后,当您在 pom.xml 中通过 id 引用此注册表时,它会自动登录。

    必须使用oauth2accesstoken 作为用户名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      • 2017-11-09
      • 1970-01-01
      • 2023-03-07
      • 2021-12-10
      相关资源
      最近更新 更多