简体   繁体   English

Docker ImagePush失败,“没有基本身份验证凭据”

[英]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've verified that the credentials string I'm passing in is a base64 encoded user:pass for the ECR registry. 我已验证我传递的凭据字符串是ECR注册表的base64编码的user:pass。
  • I've verified that the ECR credentials I'm getting are from the same AWS Region as where im attempting to push the image. 我已验证我获得的ECR凭证与尝试推送图像的地点来自同一AWS区域。

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.

相关问题 “没有基本的身份验证凭据” docker push - “no basic auth credentials” docker push 将 docker 映像推送到 aws ecr 不会提供基本的身份验证凭据 - Pushing a docker image to aws ecr gives no basic auth credentials Docker推送到AWS ECR在Windows上失败:没有基本身份验证凭据 - Docker push to AWS ECR fails on Windows: no basic auth credentials AWS CodePipeline Docker 推送命令返回“无基本身份验证凭证” - AWS CodePipeline Docker push command returns 'no basic auth credentials' 尝试将docker-image资源推送到AWS ECR时使用“无基本身份验证凭证” - Concourse “no basic auth credentials” when trying to push with docker-image resource to AWS ECR 尝试从专用ECR提取图像时“没有基本身份验证凭据” - “no basic auth credentials” when trying to pull an image from a private ECR 无法将图像推送到 Amazon ECR - 因“没有基本身份验证凭证”而失败 - Can't push image to Amazon ECR - fails with "no basic auth credentials" 无法将映像推送到ECS专用注册表-没有基本的身份验证凭据 - Can't push an image to ECS Private Registry - no basic auth credentials 在EC2实例上使用IAM角色“无基本身份验证凭据” - “No basic auth credentials” using IAM role on EC2 instance 无法推送图像 - 因“没有基本身份验证凭据”而失败 - Can't push image - fails with "no basic auth credentials"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM