1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

Apply build labels to images with only a FROM tag.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-03-30 17:26:02 -04:00
parent 8dabc0c39b
commit 1a85c8ebbe
4 changed files with 66 additions and 9 deletions

View File

@ -222,6 +222,17 @@ func (b *Builder) build(config *types.ImageBuildOptions, context builder.Context
}
return "", err
}
// Commit the layer when there are only one children in
// the dockerfile, this is only the `FROM` tag, and
// build labels. Otherwise, the new image won't be
// labeled properly.
// Commit here, so the ID of the final image is reported
// properly.
if len(b.dockerfile.Children) == 1 && len(b.options.Labels) > 0 {
b.commit("", b.runConfig.Cmd, "")
}
shortImgID = stringid.TruncateID(b.image)
fmt.Fprintf(b.Stdout, " ---> %s\n", shortImgID)
if b.options.Remove {