mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Send corrent endpoint authentication when an image is pulled during the run
cmd.
This commit is contained in:
parent
da3bb9a7c6
commit
ad322d7cca
1 changed files with 19 additions and 0 deletions
19
commands.go
19
commands.go
|
@ -1432,6 +1432,25 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
repos, tag := utils.ParseRepositoryTag(config.Image)
|
repos, tag := utils.ParseRepositoryTag(config.Image)
|
||||||
v.Set("fromImage", repos)
|
v.Set("fromImage", repos)
|
||||||
v.Set("tag", tag)
|
v.Set("tag", tag)
|
||||||
|
|
||||||
|
// Resolve the Repository name from fqn to endpoint + name
|
||||||
|
var endpoint string
|
||||||
|
endpoint, _, err = registry.ResolveRepositoryName(repos)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the auth config file, to be able to pull the image
|
||||||
|
cli.LoadConfigFile()
|
||||||
|
|
||||||
|
// Resolve the Auth config relevant for this server
|
||||||
|
authConfig := cli.configFile.ResolveAuthConfig(endpoint)
|
||||||
|
buf, err := json.Marshal(authConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
v.Set("authConfig", base64.URLEncoding.EncodeToString(buf))
|
||||||
|
|
||||||
err = cli.stream("POST", "/images/create?"+v.Encode(), nil, cli.err)
|
err = cli.stream("POST", "/images/create?"+v.Encode(), nil, cli.err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue