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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With