如何使用具有授权的io.fabric8 Maven插件将Docker映像推送到Amazon ECR [英] How to push docker image to Amazon ECR using io.fabric8 maven plugin with authorization

查看:285
本文介绍了如何使用具有授权的io.fabric8 Maven插件将Docker映像推送到Amazon ECR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于创建图片的插件,创建后需要将其推送到亚马逊ECR 请在下面查看我的插件`

I have a plugin to create a image, once created it need to be pushed to amazon ECR Please look into my plugin in the below`

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
   <groupId>io.fabric8</groupId>
   <artifactId>docker-maven-plugin</artifactId>
   <version>0.24.0</version>
   <configuration>
      <dockerHost>https://accountID.dkr.ecr.us-east-1.amazonaws.com</dockerHost>
      <authConfig>
         <authToken>authorization Token</authToken>
         <username>Access Key ID</username>
         <password>Secret Key Id</password>
      </authConfig>
      <images>
         <image>
            <alias>service</alias>
            <name>${project.artifactId}</name>
            <build>
               <from>openjdk:8-jdk-alpine</from>
               <entryPoint>
                  <exec>
                     <arg>java</arg>
                     <arg>-jar</arg>
                     <arg>maven/app.jar</arg>
                  </exec>
               </entryPoint>
               <assembly>
                  <descriptorRef>artifact-with-dependencies</descriptorRef>
               </assembly>
            </build>
         </image>
      </images>
   </configuration>
   <executions>
      <execution>
         <id>docker-build</id>
         <goals>
            <goal>build</goal>
         </goals>
      </execution>
   </executions>
</plugin>

`

我尝试使用授权令牌为authtoken的上述插件.当我运行Maven build时,未获得授权.

I have tried with above plugin with authorization token as authtoken . when i am running maven build getting not authorized .

我们将为您提供帮助

谢谢, 达莫达

推荐答案

您可以使用 AWS ECR凭证助手

请阅读文档以获取更多详细信息,但这是使其正常工作的主要步骤:

Please read the documentation for further details, but here are the major steps to get it working:

  1. 已设置AWS凭证(例如〜/.aws/credentials)
  2. 安装ECR凭据帮助程序
  3. 调整您的〜/.docker/config.json (对我们来说,这是第二个提到的具有特定AWS帐户ID的选项)
  1. AWS credentials are set up (e.g. ~/.aws/credentials)
  2. install the ECR credential helper
  3. Adapt your ~/.docker/config.json (for us it has been the second mentioned option with specific aws account id)

{
  "credHelpers": {
    "accountID.dkr.ecr.us-east-1.amazonaws.com": "ecr-login"
  },
  ... (already existing stuff in my setup)
}

  1. 在执行fabric8 maven-docker-plugin的外壳中使用正确的环境变量:

AWS_SDK_LOAD_CONFIG=true
AWS_PROFILE=your_aws_profile

也许您还需要将 AWS_REGION 定义为环境变量.

Maybe you will need to define AWS_REGION as environment variable as well.

现在,当运行Maven构建时,ECR凭据帮助程序应负责身份验证过程,因此可以删除问题中配置的"authConfig"部分.

Now when running the maven build, the ECR credential helper should take care of the authentication process, so the "authConfig"-part of the config in the question can be removed.

这篇关于如何使用具有授权的io.fabric8 Maven插件将Docker映像推送到Amazon ECR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆