Golang moby authentication in google container
I am using google container registry to host my docker images. I am also using the moby client for golang to interact with it. I am using a JSON service key approach which seems to work fine with RegistryLogin. Response text - completed successfully. However, I have no idea how to use the returned authentication key with ImagePull. When setting up the hood, RegistryAuth seems to set whatever string passed as the X-Registry-Auth header, Google doesn't seem to mention this anywhere.
I tried passing the returned key as RegistryAuth, I tried to start RegistryLogin and then just pulled without RegistryAuth. I've tried base64 encoding my auth config and submitting it to RegistryAuth. Regardless of what I try to get, I get "Error response from daemon: repository xxx not found: does not exist or cannot be accessed." Launching docker login and then docker run with the same details works fine on the cli. My code:
authConfig := types.AuthConfig{
Username: "_json_key",
Password: string(decodedKey),
ServerAddress: "https://gcr.io",
}
_, err = engine.Client.RegistryLogin(ctx, authConfig)
if err != nil {
return err
}
responseBody, err := engine.Client.ImagePull(ctx, image, types.ImagePullOptions{
})
defer responseBody.Close()
if err != nil {
return err
}
decodedKey is the content of the JSON key file. Any ideas how to get this to work?
source to share
No one has answered this question yet
See similar questions:
or similar: