summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/image/image.go2
-rw-r--r--test/e2e/rmi_test.go35
2 files changed, 36 insertions, 1 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 0e236503d..112eeb015 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -363,7 +363,7 @@ func (i *Image) Remove(force bool) error {
}
// Do not remove if image is a base image and is not untagged, or if
// the image has more children.
- if (nextParent == nil && len(parent.Names()) > 0) || len(children) > 0 {
+ if len(children) > 0 || len(parent.Names()) > 0 {
return nil
}
id := parent.ID()
diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go
index 2d096d7ba..0fdfa6797 100644
--- a/test/e2e/rmi_test.go
+++ b/test/e2e/rmi_test.go
@@ -141,6 +141,41 @@ var _ = Describe("Podman rmi", func() {
Expect(session.ExitCode()).To(Not(Equal(0)))
})
+ It("podman rmi image that is created from another named imaged", func() {
+ session := podmanTest.Podman([]string{"rmi", "-fa"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"run", "--name", "c_test1", ALPINE, "true"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"commit", "-q", "c_test1", "test1"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"run", "--name", "c_test2", "test1", "true"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"commit", "-q", "c_test2", "test2"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"rm", "-a"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"rmi", "test2"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"images", "-q"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+ })
+
It("podman rmi with cached images", func() {
session := podmanTest.Podman([]string{"rmi", "-fa"})
session.WaitWithDefaultTimeout()