1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Make the FROM instruction pull the image if not existing

This commit is contained in:
Guillaume J. Charmes 2013-05-01 15:06:23 -07:00
parent 4ebec08add
commit 924b61328c

View file

@ -198,8 +198,27 @@ func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, e
fmt.Fprintf(stdout, "FROM %s\n", arguments) fmt.Fprintf(stdout, "FROM %s\n", arguments)
image, err = builder.runtime.repositories.LookupImage(arguments) image, err = builder.runtime.repositories.LookupImage(arguments)
if err != nil { if err != nil {
if builder.runtime.graph.IsNotExist(err) {
if builder.runtime.graph.LookupRemoteImage(arguments, builder.runtime.authConfig) {
if err := builder.runtime.graph.PullImage(stdout, arguments, builder.runtime.authConfig); err != nil {
return nil, err return nil, err
} }
} else {
// FIXME: Allow pull repo:tag
if err := builder.runtime.graph.PullRepository(stdout, arguments, "", builder.runtime.repositories, builder.runtime.authConfig); err != nil {
return nil, err
}
}
image, err = builder.runtime.repositories.LookupImage(arguments)
if err != nil {
return nil, err
}
} else {
return nil, err
}
}
break break
case "run": case "run":
fmt.Fprintf(stdout, "RUN %s\n", arguments) fmt.Fprintf(stdout, "RUN %s\n", arguments)