无法对 ECR 使用 "Docker push" 命令
Unable to use the "Docker push" command with ECR
由于 ECR 登录问题,我无法使用 Bamboo 中的 "Docker" 任务将 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
我发现 aws ecr get-login
命令正在生成前缀为 https://
的 URL。为了让 Bamboo 推送到我的存储库,我不得不从使用 Bamboo 任务切换到使用自定义 bash 脚本,该脚本将 "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 ;}' | 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
I would be interested to know if anyone has a more elegant solution than dropping back to a bash script.
如果您正在寻找基于非脚本的解决方案,您可能对 Utoolity 的 Identity Federation for AWS (Bamboo) add-on (commercial, see disclaimer), which provides a dedicated Amazon ECR Credentials Variables 任务感兴趣,该任务为其他工具和 注入临时 Amazon EC2 Container Registry (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 的联合创始人。
由于 ECR 登录问题,我无法使用 Bamboo 中的 "Docker" 任务将 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
我发现 aws ecr get-login
命令正在生成前缀为 https://
的 URL。为了让 Bamboo 推送到我的存储库,我不得不从使用 Bamboo 任务切换到使用自定义 bash 脚本,该脚本将 "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 ;}' | 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
I would be interested to know if anyone has a more elegant solution than dropping back to a bash script.
如果您正在寻找基于非脚本的解决方案,您可能对 Utoolity 的 Identity Federation for AWS (Bamboo) add-on (commercial, see disclaimer), which provides a dedicated Amazon ECR Credentials Variables 任务感兴趣,该任务为其他工具和 注入临时 Amazon EC2 Container Registry (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 的联合创始人。