mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #29550 from LK4D4/fix_commit
commit: do not change container labels on commit
This commit is contained in:
commit
dc8a6d91fb
2 changed files with 16 additions and 4 deletions
|
@ -65,11 +65,10 @@ func merge(userConf, imageConf *containertypes.Config) error {
|
||||||
if userConf.Labels == nil {
|
if userConf.Labels == nil {
|
||||||
userConf.Labels = map[string]string{}
|
userConf.Labels = map[string]string{}
|
||||||
}
|
}
|
||||||
if imageConf.Labels != nil {
|
for l, v := range imageConf.Labels {
|
||||||
for l := range userConf.Labels {
|
if _, ok := userConf.Labels[l]; !ok {
|
||||||
imageConf.Labels[l] = userConf.Labels[l]
|
userConf.Labels[l] = v
|
||||||
}
|
}
|
||||||
userConf.Labels = imageConf.Labels
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(userConf.Entrypoint) == 0 {
|
if len(userConf.Entrypoint) == 0 {
|
||||||
|
|
|
@ -142,3 +142,16 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestCommitChangeLabels(c *check.C) {
|
||||||
|
dockerCmd(c, "run", "--name", "test", "--label", "some=label", "busybox", "true")
|
||||||
|
|
||||||
|
imageID, _ := dockerCmd(c, "commit",
|
||||||
|
"--change", "LABEL some=label2",
|
||||||
|
"test", "test-commit")
|
||||||
|
imageID = strings.TrimSpace(imageID)
|
||||||
|
|
||||||
|
c.Assert(inspectField(c, imageID, "Config.Labels"), checker.Equals, "map[some:label2]")
|
||||||
|
// check that container labels didn't change
|
||||||
|
c.Assert(inspectField(c, "test", "Config.Labels"), checker.Equals, "map[some:label]")
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue