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 {

    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

  • Use Docker Compose offline by using local images and not pulling images
  • Why do I get an error when I want to run cv2.imshow within docker container
  • how can i launch the kafka scheduler using marathon in minimesos?
  • Drupal database connection error with Docker - SQLSTATE[HY000] [2002]
  • Network connection between 2 Docker Container (JBOSS/DATABASE)
  • Docker Swarm : How to setup multiple containers on same volume
  • Login Succeeded
    panic: Error response from daemon: Get unauthorized: incorrect username or password

    While ServerAddress is, not

  • How to deploy a full (web) application using Docker, if each process must be a container?
  • How to connect to Oracle Docker image
  • Trick to loop/autorefresh docker ps view like top/htop in bash
  • How long should I wait when I run `docker-compose up`? What should I do to retry?
  • What does Docker run --storage-opt size=XYZ means?
  • How to enable Virtualisation on Windows 8?
  • 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.