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

  • How to dynamically change the docker's base image
  • Alpine variants of PHP and Apache/httpd in Docker
  • How to design Docker routing and database Layer?
  • Connecting inside container at docker environment using JSCH
  • What is location of images pulled from Docker Hub via Docker for Mac
  • docker-compose run not last image
  • Login Succeeded
    panic: Error response from daemon: Get unauthorized: incorrect username or password

    While ServerAddress is, not

  • Using Docker, how do you execute PHP composer commands?
  • docker ubuntu /bin/sh: 1: locale-gen: not found
  • How can an iptables 443 redirection on my host interfere with outbound HTTPS requests from my Docker container?
  • Why Can I not resolve and other hosts behind proxy from within Vagrant VM
  • Pass “volume-driver” option to kubernetes pod
  • Can't run gdbserver in a Docker container for the Visual C++ for Linux Development
  • 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.