Docker API 1.39从ECR存储库构建映像

时间:2019-03-10 11:55:32

标签: amazon-web-services docker amazon-ec2 docker-api amazon-ecr

说明

Docker API v1.37“构建”端点返回错误no basic auth credentials

我有几个ECR存储库,我正在运行一个EC2实例,该实例具有附加的实例配置文件角色,并具有对ECR的完全许可权。

我正在远程EC2实例上运行docker守护程序,两个实例都具有对ECR的完全权限。

我正在尝试使用docker API执行构建操作,Dockerfile包含一条FROM语句,该语句指向我的一个ECR存储库中的图像之一。

这就是我想要做的。

password=$(aws ecr get-login --no-include-email --output text --region us-east-2 | awk '{printf $6}') registryAuth=$(echo -n '{"username": "AWS", password: "'$password'", "serveraddress": "https://my_aws_account.dkr.ecr.us-east-2.amazonaws.com/v2/"}'| base64 -w0)

我尝试为server

使用各种选项
  1. https://my_aws_account.dkr.ecr.us-east-2.amazonaws.com/v1/
  2. https://my_aws_account.dkr.ecr.us-east-2.amazonaws.com/
  3. https://my_aws_account.dkr.ecr.us-east-2.amazonaws.com/v2/

curl -v -X POST --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -H "X-Registry-Auth: $registryAuth" -H "Content-Type:application/tar" --data-binary '@Dockerfile.tar.gz' http://localhost:2375/v1.37/build

我遇到相同的错误

* upload completely sent off: 188 out of 188 bytes
< HTTP/1.1 200 OK
< Api-Version: 1.39
< Content-Type: application/json
< Docker-Experimental: false
< Ostype: linux
< Server: Docker/18.09.3 (linux)
< Date: Thu, 07 Mar 2019 16:02:27 GMT
< Transfer-Encoding: chunked
<
{"stream":"Step 1/1 : FROM my_aws_account.dkr.ecr.us-east-2.amazonaws.com/slicer_base:latest"}
{"stream":"\n"}
{"errorDetail":{"message":"Get https://my_aws_account.dkr.ecr.us-east-2.amazonaws.com/v2/slicer_base/manifests/latest: no basic auth credentials"},"error":"Get https://my_aws_account.dkr.ecr.us-east-2.amazonaws.com/v2/slicer_base/manifests/latest: no basic auth credentials"}
* Connection #0 to host localhost left intact

我是否需要将aws ecr get-login的{​​{1}}或aws ecr get-authorization-token传递到password的{​​{1}},应该使用base64编码?

我尝试了registryAuthaws ecr get-login这两个选项,但它们都不适合我。

这是我的aws ecr get-authorization-token启动配置: dockerd

/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock的输出:

docker version

Client: Version: 18.09.3 API version: 1.39 Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:40:58 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.3 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 05:59:55 2019 OS/Arch: linux/amd64 Experimental: false 的输出:

docker info

此问题与已经here打开的另一个问题/问题有关

0 个答案:

没有答案