Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failure to Push Docker Image to ECR w/ Docker Go SDK

Tags:

go

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

like image 753
John Giotta Avatar asked Jun 06 '17 22:06

John Giotta


People also ask

How do I push an image to public ECR repository?

Identify the image to push. Run the docker images command to list the images on your system. You can identify an image with the repository:tag value or the image ID in the resulting command output. Tag your image with the Amazon ECR public registry, public repository, and optional image tag name combination to use.

How do I move a docker image to AWS ECR?

Identify the local image to push. Run the docker images command to list the container images on your system. You can identify an image with the repository:tag value or the image ID in the resulting command output. Tag your image with the Amazon ECR registry, repository, and optional image tag name combination to use.

What is docker push?

Docker Push is a command that is used to push or share a local Docker image or a repository to a central repository; it might be a public registry like https://hub.docker.com or a private registry or a self-hosted registry.


1 Answers

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.

like image 100
Adrien BARRAL Avatar answered Oct 04 '22 12:10

Adrien BARRAL