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
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.