I created a Private Registry using following command:
docker run -d -p 5000:5000 --restart=always --name registry -e REGISTRY_STORAGE_DELETE_ENABLED=true registry:2
I am trying to push Images to this registry using Golang docker client API -> ImagePush
func (cli *Client) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)
When I zoom into ImagePushOptions I see that struct is
type ImagePullOptions struct {
All bool
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
PrivilegeFunc RequestPrivilegeFunc
}
AnyIdea how to create RegistryAuth String
I tried doing following:
type AuthArgs struct {
Username string json:"username"
Password string json:"password"
Email string json:"email"
ServerAddress string json:"serveraddress"
}
func() {
m := AuthArgs{"docker", "docker", "", "localhost:5000"}
b, err := json.Marshal(m)
fmt.Println(string(b))
encodeStr := base64.StdEncoding.EncodeToString(b)
refStr := "localhost:5000/" + image + ":" + tag
fmt.Println(refStr)
resp, err := cli.ImagePush(ctx, refStr, types.ImagePushOptions{RegistryAuth: encodeStr })
I am stuck from 3 days, any help would be great
Thanks,
Chirag