import (client2 "github.com/docker/docker/client")
authConfig := types.AuthConfig{Username: "admin", Password: "123456"} var encodedJSON []byte encodedJSON, err = json.Marshal(authConfig) if err != nil { return err } authStr := base64.URLEncoding.EncodeToString(encodedJSON)
cli, err := client2.NewClientWithOpts(client2.WithAPIVersionNegotiation())
pushReader, err = cli.ImagePush(context.Background(), imgName, types.ImagePushOptions{ All: false, RegistryAuth: authStr, PrivilegeFunc: nil, })