如何从自定义码头工人注册表拉图像与golang?

问题描述 投票:1回答:1

使用泊坞窗来源如何从自定义注册表拉形象?作为使用这样的代码的结果

// 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

虽然serveraddress为registry.gitlab.com,不registry-1.docker.io

go docker
1个回答
0
投票

你检查身份令牌?这可能导致身份验证问题。

一条建议: Docker client

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

© www.soinside.com 2019 - 2024. All rights reserved.