英文:
Failure to Push Docker Image to ECR w/ Docker Go SDK
问题
我正在使用Go的Docker客户端SDK,并且在将镜像推送到我的AWS ECR时遇到了问题。
以下是我的函数的要点:
import (
"github.com/docker/docker/api/types"
dockerclient "github.com/docker/docker/client"
)
func doPush(target string) {
envCli, err := dockerclient.NewEnvClient()
if err != nil {
panic(err)
}
rc, err := envCli.ImagePush(
context.Background(),
target,
types.ImagePushOptions{})
if err != nil {
panic(err)
}
defer rc.Close()
}
我的镜像标记类似于 [regid].dkr.ecr.us-east-1.amazonaws.com/demo:latest
,但是我收到以下错误消息:
无效的引用格式
如果我从镜像名称中删除 [:tag]
,它可以工作,直到我收到以下错误消息:
来自守护程序的错误响应:错误的参数和缺少 X-Registry-Auth: EOF
英文:
I'm using the docker client SDK for Go and I'm running to an issue with pushing images to my AWS ECR.
Here is the gist of my func
import (
"github.com/docker/docker/api/types"
dockerclient "github.com/docker/docker/client"
)
func doPush(target string) {
envCli, err := dockerclient.NewEnvClient()
if err != nil {
panic(err)
}
rc, err := envCli.ImagePush(
context.Background(),
target,
types.ImagePushOptions{})
if err != nil {
panic(err)
}
defer rc.Close()
}
My image is tagged something like [regid].dkr.ecr.us-east-1.amazonaws.com/demo:latest but I get the following error:
> invalid reference format
If I remove the [:tag] from the image name, it works until I get a
> Error response from daemon: Bad parameters and missing X-Registry-Auth: EOF
答案1
得分: 4
我遇到了同样的问题,并通过给docker push选项提供一个任意的RegistryAuth来解决了它。
所以以下代码可以工作:
closer, err = dockerClient.ImagePush(context.Background(), privateTagName,
types.ImagePushOptions{
All: true,
RegistryAuth: "123",
})
if err != nil {
panic(err)
}
io.Copy(os.Stdout, closer)
closer.Close()
我在这篇帖子中读到,给RegistryAuth赋予任何值都可能起作用。
英文:
I had the same problem, and I solved it giving an arbitrary RegistryAuth to the docker push option.
So the following code works :
closer, err = dockerClient.ImagePush(context.Background(), privateTagName,
types.ImagePushOptions{
All: true,
RegistryAuth:"123",
})
if err != nil{
panic(err)
}
io.Copy(os.Stdout, closer)
closer.Close()
I read in this post that giving any value to RegistryAuth could work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论