How to pull image from custom docker registry with golang?

Using docker sources how to pull image from custom registry? As a result of using such code

// Prepare auth registry for usage
func (app *App) PrepareRegistry() error {
    app.AuthConfig = types.AuthConfig{
        Username:      Username,
        Password:      Password,
        ServerAddress: DefaultServer,
    }

    resp, err := app.Client.RegistryLogin(context.Background(), app.AuthConfig)
    if err != nil {
        panic(err)
    }

    fmt.Println(resp.Status)
    if resp.IdentityToken != "" {
        app.AuthConfig.IdentityToken = resp.IdentityToken
    }

    app.AuthConfigEncoded, err = command.EncodeAuthToBase64(app.AuthConfig)
    return err
}

func (app *App) ImagePull() error {

    opts := types.ImagePullOptions{
        All:            true,
        RegistryAuth: app.AuthConfigEncoded,
        PrivilegeFunc: registryAuthentication(app.Name),
    }
    responseBody, err := app.Client.ImagePull(context.Background(), app.Name, opts)
    defer responseBody.Close()
    if err != nil {
        return err
    }
    return nil
}

I am still getting the error

  • Json schema Draft v4 to markdown documentation
  • Docker Datacenter: Error x509 certificate signed by unknown authority UCP 2.0.0 and DTR 2.1.0 with external certificates
  • Which capabilities can I drop in a Docker Nginx container?
  • How to mount HDFS in a Docker container
  • Running gunicorn inside heroku docker
  • Customer params in kubectl when run docker
  • Login Succeeded
    panic: Error response from daemon: Get https://registry-1.docker.io/v2/shalakhin/blender/tags/list: unauthorized: incorrect username or password
    

    While ServerAddress is registry.gitlab.com, not registry-1.docker.io

  • error running docker inside docker
  • How to run Docker container and watch the logs in one single command
  • Windows Server 2016 Dockerfile install service
  • unable to edit /etc/resolv.conf in docker container
  • How to remote debug python code in a Docker Container with VS Code
  • Docker-compose - volumes driver local meaning
  • One Solution collect form web for “How to pull image from custom docker registry with golang?”

    Did you check identity token? That might cause an authentication problem.

    A suggestion:
    Docker client

    This works fine, as I can see you did not specify the endpoint. I think you should add this info.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.