mirror of
https://github.com/docker/cli.git
synced 2026-09-26 09:20:58 -04:00
Fix rmi by ID untagging image on error
Do not untag image if it would later get a hard conflict because of running containers. Fixes #18873 Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> Upstream-commit: 38a45eed8850a15d2f737ce7455f29c5ae53ab49 Component: engine
This commit is contained in:
@@ -337,3 +337,20 @@ func (s *DockerSuite) TestRmiWithParentInUse(c *check.C) {
|
||||
|
||||
dockerCmd(c, "rmi", imageID)
|
||||
}
|
||||
|
||||
// #18873
|
||||
func (s *DockerSuite) TestRmiByIDHardConflict(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
dockerCmd(c, "create", "busybox")
|
||||
|
||||
imgID, err := inspectField("busybox:latest", "Id")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
_, _, err = dockerCmdWithError("rmi", imgID[:12])
|
||||
c.Assert(err, checker.NotNil)
|
||||
|
||||
// check that tag was not removed
|
||||
imgID2, err := inspectField("busybox:latest", "Id")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(imgID, checker.Equals, imgID2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user