1
使用碼頭源如何從自定義註冊表中拉出圖像?作爲使用這種代碼的結果如何從自定義碼頭註冊表與golang拉圖像?
// 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
這裏定義了所有這些函數/類型,比如'app.Client',你在使用什麼庫?可能需要[mcve](http://stackoverflow.com/help/mcve)。 – BMitch
我使用docker源代碼。我有持有碼頭客戶端,應用程序名稱(我們可以說圖像名稱)等應用程序結構 – shalakhin