duanqiang2977 2018-12-04 21:11
浏览 520

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

I'm attempting to use the docker go-sdk to push an image to AWS ECR.

This is the code I'm using to push the image.

where tag = ".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.
  • I've verified that the ECR credentials I'm getting are from the same AWS Region as where im attempting to push the image.
  • 写回答

1条回答 默认 最新

  • 普通网友 2018-12-04 21:24
    关注

    I found out in a GitHub comment that RegistryAuth actually needs to be a base64 JSON string with username and password fields. Ugh. This is undocumented in the Docker repository.

    RegistryAuth = "{ \"username\": \"myusername\", \"password\": \"mypassword\", \"email\": \"myemail\" }
    

    Relevant GitHub comment.

    It is working for me now.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用