Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用golang从自定义docker注册表中提取图像?_Go_Docker - Fatal编程技术网

如何使用golang从自定义docker注册表中提取图像?

如何使用golang从自定义docker注册表中提取图像?,go,docker,Go,Docker,使用docker源如何从自定义注册表中提取图像?由于使用了这样的代码 // Prepare auth registry for usage func (app *App) PrepareRegistry() error { app.AuthConfig = types.AuthConfig{ Username: Username, Password: Password, ServerAddress: DefaultSer

使用docker源如何从自定义注册表中提取图像?由于使用了这样的代码

// 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
}
我仍然得到错误

Login Succeeded
panic: Error response from daemon: Get https://registry-1.docker.io/v2/shalakhin/blender/tags/list: unauthorized: incorrect username or password

服务器地址是registry.gitlab.com,而不是registry-1.docker.io

您是否检查了标识令牌?这可能会导致身份验证问题

建议:


这很好,因为我可以看到您没有指定端点。我想你应该添加这个信息

所有这些函数/类型都是在哪里定义的,比如
app.Client
,您使用的是什么库?可能需要一个。我使用docker源代码。我有一个包含docker客户端的应用程序结构,应用程序名(我们可以说是图像名)等等@shalakhin你解决了这个问题吗?另外,我可以知道您正在使用的docker源代码(github链接)吗?