我无法使用" Docker" Bamboo中的任务由于ECR登录问题而将Docker映像推送到AWS Elastic Container Repository(ECR)。我的输出如下:
build 18-Oct-2016 12:11:54 9007f5987db3: Preparing
build 18-Oct-2016 12:11:54 b718b2f27b6c: Waiting
build 18-Oct-2016 12:11:54 c986610bcfe6: Waiting
build 18-Oct-2016 12:11:54 ee16ea28e998: Waiting
build 18-Oct-2016 12:11:54 a709d74a4732: Waiting
build 18-Oct-2016 12:11:54 c672d981aff9: Waiting
build 18-Oct-2016 12:11:54 17287d14d5b6: Waiting
build 18-Oct-2016 12:11:54 4505f2891620: Waiting
build 18-Oct-2016 12:11:54 94102dff0575: Waiting
build 18-Oct-2016 12:11:54 e83e87cb73c3: Waiting
build 18-Oct-2016 12:11:54 740e5e49ea89: Waiting
build 18-Oct-2016 12:11:54 092e6cb28bdb: Waiting
build 18-Oct-2016 12:11:54 9007f5987db3: Waiting
build 18-Oct-2016 12:11:54 8d94959a46f4: Waiting
build 18-Oct-2016 12:11:54 d2ccc68b6943: Waiting
build 18-Oct-2016 12:11:54 3dc6be5926c6: Waiting
build 18-Oct-2016 12:11:54 0afc75223403: Waiting
build 18-Oct-2016 12:11:54 71caa5138f3c: Waiting
build 18-Oct-2016 12:11:54 1be454502782: Waiting
build 18-Oct-2016 12:11:54 4a2173830433: Waiting
error 18-Oct-2016 12:11:54 error parsing HTTP 403 response body: invalid character 'Y' looking for beginning of value: "Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one."
simple 18-Oct-2016 12:11:54 Failing task since return code of [/bin/sh /tmp/WEB-SYNAPICI-JOB1-11-ScriptBuildTask-245668070788779382.sh] was 1 while expected 0
答案 0 :(得分:2)
我发现aws ecr get-login
命令生成了一个前缀为https://
的网址。为了让Bamboo推送到我的存储库,我不得不从使用Bamboo任务切换到使用自动删除" https://"在docker login
命令的前面,以便登录的存储库与正在推送到的存储库具有完全相同的URL。
我觉得这可能是AWS客户端的一个错误,但这是我的脚本以防其他人发现它有用:
#!/usr/bin/env bash
docker_login_command=$(aws ecr get-login)
$(echo $docker_login_command | sed 's|https://||' | sed 's|-e none ||')
container_id=$(docker images | grep foo | awk '{print $3;}' | uniq)
echo $container_id
url="output-of-the-ecr-create-repository-command.dkr.ecr.eu-west-1.amazonaws.com/bar/foo"
docker tag $container_id $url
docker push $url
答案 1 :(得分:0)
我很想知道是否有人比回到bash脚本有更优雅的解决方案。
如果您正在寻找基于非脚本的解决方案,您可能会对Utoolity的Identity Federation for AWS (Bamboo)插件(商业广告,请参阅免责声明)感兴趣,该插件可为注入提供专用的Amazon ECR Credentials Variables任务其他工具的临时Amazon EC2容器注册表(Amazon ECR)身份验证凭据和AWS未知任务(如Bamboo Docker任务)。
具体来说,它会创建以下变量,您可以在后续任务中需要ECR凭据的任何地方引用它们(前提是它们正确支持Bamboo变量):
${bamboo.custom.aws.ecr.proxyEndpointDomain}
${bamboo.custom.aws.ecr.username}
${bamboo.custom.aws.ecr.password}
请参阅How to push a Docker image to a repository in your Amazon ECR registry with the Bamboo Docker task了解分步指南。
免责声明:我是此附加组件供应商Utoolity的联合创始人。