[英]Docker ImagePush failing with “no basic auth credentials”
I'm attempting to use the docker go-sdk to push an image to AWS ECR. 我正在尝试使用docker go-sdk将映像推送到AWS ECR。
This is the code I'm using to push the image. 这是我用来推送图像的代码。
where tag = ".dkr.ecr.us-east-1.amazonaws.com/api:mytag" 其中标记=“ .dkr.ecr.us-east-1.amazonaws.com / api:mytag”
func Push(c context.Context, tag string, credentials string) error {
cli, err := client.NewClient(apiSocket, apiVersion, nil, apiHeaders)
if err != nil {
return err
}
fmt.Println(credentials)
resp, err := cli.ImagePush(c, tag, types.ImagePushOptions{
RegistryAuth: credentials,
})
if err != nil {
panic(err)
}
io.Copy(os.Stdout, resp)
resp.Close()
return nil
}
But I keep getting this response: 但我一直得到这个回应:
{"status":"The push refers to repository [<id>.dkr.ecr.us-east-1.amazonaws.com/api]"}
{"status":"Preparing","progressDetail":{},"id":"23432919a50a"}
{"status":"Preparing","progressDetail":{},"id":"9387ad10e44c"}
{"status":"Preparing","progressDetail":{},"id":"e2a4679276bf"}
{"status":"Preparing","progressDetail":{},"id":"31c5c8035e63"}
{"status":"Preparing","progressDetail":{},"id":"a73789d39a06"}
{"status":"Preparing","progressDetail":{},"id":"f36942254806"}
{"status":"Preparing","progressDetail":{},"id":"4a2596f9aa79"}
{"status":"Preparing","progressDetail":{},"id":"5cf3066ccdbc"}
{"status":"Preparing","progressDetail":{},"id":"76a1661c28fc"}
{"status":"Preparing","progressDetail":{},"id":"beefb6beb20f"}
{"status":"Preparing","progressDetail":{},"id":"df64d3292fd6"}
{"status":"Waiting","progressDetail":{},"id":"beefb6beb20f"}
{"status":"Waiting","progressDetail":{},"id":"df64d3292fd6"}
{"errorDetail":{"message":"no basic auth credentials"},"error":"no basic auth credentials"}
Any ideas? 有任何想法吗?
Notes: 笔记:
I found out in a GitHub comment that RegistryAuth
actually needs to be a base64 JSON string with username and password fields. 我在GitHub评论中发现, RegistryAuth
实际上必须是带有用户名和密码字段的base64 JSON字符串。 Ugh. 啊。 This is undocumented in the Docker repository. Docker存储库中未对此进行记录。
RegistryAuth = "{ \"username\": \"myusername\", \"password\": \"mypassword\", \"email\": \"myemail\" }
Relevant GitHub comment . 相关GitHub评论 。
It is working for me now. 现在对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.