github.com/containers/podman/v4@v4.9.4/test/e2e/images_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"fmt"
     5  	"sort"
     6  	"strings"
     7  
     8  	. "github.com/containers/podman/v4/test/utils"
     9  	"github.com/docker/go-units"
    10  	. "github.com/onsi/ginkgo/v2"
    11  	. "github.com/onsi/gomega"
    12  	. "github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var _ = Describe("Podman images", func() {
    16  
    17  	It("podman images", func() {
    18  		session := podmanTest.Podman([]string{"images"})
    19  		session.WaitWithDefaultTimeout()
    20  		Expect(session).Should(ExitCleanly())
    21  		Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
    22  		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine")))
    23  		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox")))
    24  	})
    25  
    26  	It("podman image List", func() {
    27  		session := podmanTest.Podman([]string{"image", "list"})
    28  		session.WaitWithDefaultTimeout()
    29  		Expect(session).Should(ExitCleanly())
    30  		Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
    31  		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine")))
    32  		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox")))
    33  	})
    34  
    35  	It("podman images with multiple tags", func() {
    36  		// tag "docker.io/library/alpine:latest" to "foo:{a,b,c}"
    37  		podmanTest.AddImageToRWStore(ALPINE)
    38  		session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"})
    39  		session.WaitWithDefaultTimeout()
    40  		Expect(session).Should(ExitCleanly())
    41  		// tag "foo:c" to "bar:{a,b}"
    42  		session = podmanTest.Podman([]string{"tag", "foo:c", "bar:a", "bar:b"})
    43  		session.WaitWithDefaultTimeout()
    44  		Expect(session).Should(ExitCleanly())
    45  		// check all previous and the newly tagged images
    46  		session = podmanTest.Podman([]string{"images"})
    47  		session.WaitWithDefaultTimeout()
    48  		Expect(session).Should(ExitCleanly())
    49  		Expect(session.LineInOutputContainsTag("quay.io/libpod/alpine", "latest")).To(BeTrue())
    50  		Expect(session.LineInOutputContainsTag("quay.io/libpod/busybox", "latest")).To(BeTrue())
    51  		Expect(session.LineInOutputContainsTag("localhost/foo", "a")).To(BeTrue())
    52  		Expect(session.LineInOutputContainsTag("localhost/foo", "b")).To(BeTrue())
    53  		Expect(session.LineInOutputContainsTag("localhost/foo", "c")).To(BeTrue())
    54  		Expect(session.LineInOutputContainsTag("localhost/bar", "a")).To(BeTrue())
    55  		Expect(session.LineInOutputContainsTag("localhost/bar", "b")).To(BeTrue())
    56  		session = podmanTest.Podman([]string{"images", "-qn"})
    57  		session.WaitWithDefaultTimeout()
    58  		Expect(session).Should(ExitCleanly())
    59  		Expect(session.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)))
    60  	})
    61  
    62  	It("podman images with digests", func() {
    63  		session := podmanTest.Podman([]string{"images", "--digests"})
    64  		session.WaitWithDefaultTimeout()
    65  		Expect(session).Should(ExitCleanly())
    66  		Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
    67  		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine")))
    68  		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox")))
    69  	})
    70  
    71  	It("podman empty images list in JSON format", func() {
    72  		session := podmanTest.Podman([]string{"images", "--format=json", "not-existing-image"})
    73  		session.WaitWithDefaultTimeout()
    74  		Expect(session).Should(ExitCleanly())
    75  		Expect(session.OutputToString()).To(BeValidJSON())
    76  	})
    77  
    78  	It("podman images in JSON format", func() {
    79  		session := podmanTest.Podman([]string{"images", "--format=json"})
    80  		session.WaitWithDefaultTimeout()
    81  		Expect(session).Should(ExitCleanly())
    82  		Expect(session.OutputToString()).To(BeValidJSON())
    83  	})
    84  
    85  	It("podman images in GO template format", func() {
    86  		formatStr := "{{.ID}}\t{{.Created}}\t{{.CreatedAt}}\t{{.CreatedSince}}\t{{.CreatedTime}}"
    87  		session := podmanTest.Podman([]string{"images", fmt.Sprintf("--format=%s", formatStr)})
    88  		session.WaitWithDefaultTimeout()
    89  		Expect(session).Should(ExitCleanly())
    90  	})
    91  
    92  	It("podman images with short options", func() {
    93  		session := podmanTest.Podman([]string{"images", "-qn"})
    94  		session.WaitWithDefaultTimeout()
    95  		Expect(session).Should(ExitCleanly())
    96  		Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 1))
    97  	})
    98  
    99  	It("podman images filter by image name", func() {
   100  		podmanTest.AddImageToRWStore(ALPINE)
   101  		podmanTest.AddImageToRWStore(BB)
   102  
   103  		session := podmanTest.Podman([]string{"images", "-q", ALPINE})
   104  		session.WaitWithDefaultTimeout()
   105  		Expect(session).Should(ExitCleanly())
   106  		Expect(session.OutputToStringArray()).To(HaveLen(1))
   107  
   108  		session = podmanTest.Podman([]string{"tag", ALPINE, "foo:a"})
   109  		session.WaitWithDefaultTimeout()
   110  		Expect(session).Should(ExitCleanly())
   111  		session = podmanTest.Podman([]string{"tag", BB, "foo:b"})
   112  		session.WaitWithDefaultTimeout()
   113  		Expect(session).Should(ExitCleanly())
   114  
   115  		session = podmanTest.Podman([]string{"images", "-q", "foo"})
   116  		session.WaitWithDefaultTimeout()
   117  		Expect(session).Should(ExitCleanly())
   118  		Expect(session.OutputToStringArray()).To(HaveLen(2))
   119  	})
   120  
   121  	It("podman images filter by image ID", func() {
   122  		session := podmanTest.Podman([]string{"inspect", ALPINE, "--format", "{{.ID}}"})
   123  		session.WaitWithDefaultTimeout()
   124  		Expect(session).Should(ExitCleanly())
   125  		Expect(session.OutputToStringArray()).To(HaveLen(1))
   126  		imgID := session.OutputToString()
   127  
   128  		session = podmanTest.Podman([]string{"images", "--noheading", "--filter", "id=" + imgID[:5]})
   129  		session.WaitWithDefaultTimeout()
   130  		Expect(session).Should(ExitCleanly())
   131  		Expect(session.OutputToStringArray()).To(HaveLen(1))
   132  	})
   133  
   134  	It("podman images filter by image digest", func() {
   135  		session := podmanTest.Podman([]string{"inspect", ALPINE, "--format", "{{.Digest}}"})
   136  		session.WaitWithDefaultTimeout()
   137  		Expect(session).Should(ExitCleanly())
   138  		Expect(session.OutputToStringArray()).To(HaveLen(1))
   139  		imgDigest := session.OutputToString()
   140  
   141  		session = podmanTest.Podman([]string{"images", "--noheading", "--filter", "digest=" + imgDigest[:10]})
   142  		session.WaitWithDefaultTimeout()
   143  		Expect(session).Should(ExitCleanly())
   144  		Expect(session.OutputToStringArray()).To(HaveLen(1))
   145  	})
   146  
   147  	It("podman images filter reference", func() {
   148  		result := podmanTest.Podman([]string{"images", "-q", "-f", "reference=quay.io/libpod/*"})
   149  		result.WaitWithDefaultTimeout()
   150  		Expect(result).Should(ExitCleanly())
   151  		Expect(result.OutputToStringArray()).To(HaveLen(10))
   152  
   153  		retalpine := podmanTest.Podman([]string{"images", "-f", "reference=*lpine*"})
   154  		retalpine.WaitWithDefaultTimeout()
   155  		Expect(retalpine).Should(ExitCleanly())
   156  		Expect(retalpine.OutputToStringArray()).To(HaveLen(5))
   157  		Expect(retalpine.OutputToString()).To(ContainSubstring("alpine"))
   158  
   159  		retalpine = podmanTest.Podman([]string{"images", "-f", "reference=alpine"})
   160  		retalpine.WaitWithDefaultTimeout()
   161  		Expect(retalpine).Should(ExitCleanly())
   162  		Expect(retalpine.OutputToStringArray()).To(HaveLen(2))
   163  		Expect(retalpine.OutputToString()).To(ContainSubstring("alpine"))
   164  
   165  		retnone := podmanTest.Podman([]string{"images", "-q", "-f", "reference=bogus"})
   166  		retnone.WaitWithDefaultTimeout()
   167  		Expect(retnone).Should(ExitCleanly())
   168  		Expect(retnone.OutputToStringArray()).To(BeEmpty())
   169  	})
   170  
   171  	It("podman images filter before image", func() {
   172  		dockerfile := `FROM quay.io/libpod/alpine:latest
   173  RUN echo hello > /hello
   174  `
   175  		podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
   176  		result := podmanTest.Podman([]string{"images", "-q", "-f", "before=foobar.com/before:latest"})
   177  		result.WaitWithDefaultTimeout()
   178  		Expect(result).Should(ExitCleanly())
   179  		Expect(result.OutputToStringArray()).ToNot(BeEmpty())
   180  	})
   181  
   182  	It("podman images workingdir from  image", func() {
   183  		dockerfile := `FROM quay.io/libpod/alpine:latest
   184  WORKDIR /test
   185  `
   186  		podmanTest.BuildImage(dockerfile, "foobar.com/workdir:latest", "false")
   187  		result := podmanTest.Podman([]string{"run", "foobar.com/workdir:latest", "pwd"})
   188  		result.WaitWithDefaultTimeout()
   189  		Expect(result).Should(ExitCleanly())
   190  		Expect(result.OutputToString()).To(Equal("/test"))
   191  	})
   192  
   193  	It("podman images filter since/after image", func() {
   194  		dockerfile := `FROM scratch
   195  `
   196  		podmanTest.BuildImage(dockerfile, "foobar.com/one:latest", "false")
   197  		podmanTest.BuildImage(dockerfile, "foobar.com/two:latest", "false")
   198  		podmanTest.BuildImage(dockerfile, "foobar.com/three:latest", "false")
   199  
   200  		// `since` filter
   201  		result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "since=foobar.com/one:latest"})
   202  		result.WaitWithDefaultTimeout()
   203  		Expect(result).Should(ExitCleanly())
   204  		Expect(result.OutputToStringArray()).To(HaveLen(2))
   205  
   206  		// `after` filter
   207  		result = podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=foobar.com/one:latest"})
   208  		result.WaitWithDefaultTimeout()
   209  		Expect(result).Should(ExitCleanly())
   210  		Expect(result.OutputToStringArray()).Should(HaveLen(2), "list filter output: %q", result.OutputToString())
   211  	})
   212  
   213  	It("podman images filter dangling", func() {
   214  		dockerfile := `FROM quay.io/libpod/alpine:latest
   215  `
   216  		podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
   217  		podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
   218  		result := podmanTest.Podman([]string{"images", "-q", "-f", "dangling=true"})
   219  		result.WaitWithDefaultTimeout()
   220  		Expect(result).Should(Exit(0), "dangling image output: %q", result.OutputToString())
   221  		Expect(result.OutputToStringArray()).Should(BeEmpty(), "dangling image output: %q", result.OutputToString())
   222  	})
   223  
   224  	It("podman images filter intermediate", func() {
   225  		dockerfile := `FROM quay.io/libpod/alpine:latest
   226  		RUN touch /tmp/test.txt
   227  		RUN touch /tmp/test-2.txt
   228  `
   229  		podmanTest.BuildImage(dockerfile, "foobar.com/test-build", "true")
   230  		result := podmanTest.Podman([]string{"images", "--noheading", "--filter", "intermediate=true"})
   231  		result.WaitWithDefaultTimeout()
   232  		Expect(result).Should(ExitCleanly())
   233  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   234  	})
   235  
   236  	It("podman pull by digest and list --all", func() {
   237  		// Prevent regressing on issue #7651: error parsing name that includes a digest
   238  		// component as if were a name that includes tag component.
   239  		digestPullAndList := func(noneTag bool) {
   240  			session := podmanTest.Podman([]string{"pull", "-q", ALPINEAMD64DIGEST})
   241  			session.WaitWithDefaultTimeout()
   242  			Expect(session).Should(ExitCleanly())
   243  
   244  			result := podmanTest.Podman([]string{"images", "--all", ALPINEAMD64DIGEST})
   245  			result.WaitWithDefaultTimeout()
   246  			Expect(result).Should(ExitCleanly())
   247  
   248  			if noneTag {
   249  				Expect(result.OutputToString()).To(ContainSubstring("<none>"))
   250  			} else {
   251  				Expect(result.OutputToString()).To(Not(ContainSubstring("<none>")))
   252  			}
   253  		}
   254  		// No "<none>" in the tag column as image tagged as "ALPINE" should be present in
   255  		// the additional image store we're using.  Pull the same image by another name to
   256  		// copy an entry for the image into read-write storage so that the name can be
   257  		// attached to it.
   258  		session := podmanTest.Podman([]string{"pull", "-q", ALPINELISTTAG})
   259  		session.WaitWithDefaultTimeout()
   260  		Expect(session).Should(ExitCleanly())
   261  		digestPullAndList(false)
   262  
   263  		// Now remove all names from the read-write image record, re-pull by digest and
   264  		// check for the "<none>" in its listing.
   265  		session = podmanTest.Podman([]string{"untag", ALPINELISTTAG})
   266  		session.WaitWithDefaultTimeout()
   267  		Expect(session).Should(ExitCleanly())
   268  
   269  		digestPullAndList(true)
   270  	})
   271  
   272  	It("podman check for image with sha256: prefix", func() {
   273  		session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
   274  		session.WaitWithDefaultTimeout()
   275  		Expect(session).Should(ExitCleanly())
   276  		Expect(session.OutputToString()).To(BeValidJSON())
   277  		imageData := session.InspectImageJSON()
   278  
   279  		result := podmanTest.Podman([]string{"images", "sha256:" + imageData[0].ID})
   280  		result.WaitWithDefaultTimeout()
   281  		Expect(result).Should(ExitCleanly())
   282  	})
   283  
   284  	It("podman check for image with sha256: prefix", func() {
   285  		session := podmanTest.Podman([]string{"image", "inspect", "--format=json", ALPINE})
   286  		session.WaitWithDefaultTimeout()
   287  		Expect(session).Should(ExitCleanly())
   288  		Expect(session.OutputToString()).To(BeValidJSON())
   289  		imageData := session.InspectImageJSON()
   290  
   291  		result := podmanTest.Podman([]string{"image", "ls", fmt.Sprintf("sha256:%s", imageData[0].ID)})
   292  		result.WaitWithDefaultTimeout()
   293  		Expect(result).Should(ExitCleanly())
   294  	})
   295  
   296  	It("podman images sort by values", func() {
   297  		sortValueTest := func(value string, result int, format string) []string {
   298  			f := fmt.Sprintf("{{.%s}}", format)
   299  			session := podmanTest.Podman([]string{"images", "--noheading", "--sort", value, "--format", f})
   300  			session.WaitWithDefaultTimeout()
   301  			Expect(session).Should(Exit(result))
   302  
   303  			return session.OutputToStringArray()
   304  		}
   305  
   306  		sortedArr := sortValueTest("created", 0, "CreatedAt")
   307  		Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] > sortedArr[j] })).To(BeTrue())
   308  
   309  		sortedArr = sortValueTest("id", 0, "ID")
   310  		Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).To(BeTrue())
   311  
   312  		sortedArr = sortValueTest("repository", 0, "Repository")
   313  		Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).To(BeTrue())
   314  
   315  		sortedArr = sortValueTest("size", 0, "Size")
   316  		Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool {
   317  			size1, _ := units.FromHumanSize(sortedArr[i])
   318  			size2, _ := units.FromHumanSize(sortedArr[j])
   319  			return size1 < size2
   320  		})).To(BeTrue())
   321  		sortedArr = sortValueTest("tag", 0, "Tag")
   322  		Expect(sort.SliceIsSorted(sortedArr,
   323  			func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).
   324  			To(BeTrue())
   325  
   326  		sortValueTest("badvalue", 125, "Tag")
   327  		sortValueTest("id", 125, "badvalue")
   328  	})
   329  
   330  	It("test for issue #6670", func() {
   331  		expected := podmanTest.Podman([]string{"images", "--sort", "created", "--format", "{{.ID}}", "-q"})
   332  		expected.WaitWithDefaultTimeout()
   333  
   334  		actual := podmanTest.Podman([]string{"images", "--sort", "created", "-q"})
   335  		actual.WaitWithDefaultTimeout()
   336  		Expect(actual.Out).Should(Equal(expected.Out))
   337  	})
   338  
   339  	It("podman images --all flag", func() {
   340  		dockerfile := `FROM quay.io/libpod/alpine:latest
   341  RUN mkdir hello
   342  RUN touch test.txt
   343  ENV foo=bar
   344  `
   345  		podmanTest.BuildImage(dockerfile, "test", "true")
   346  		session := podmanTest.Podman([]string{"images"})
   347  		session.WaitWithDefaultTimeout()
   348  		Expect(session).Should(ExitCleanly())
   349  		Expect(session.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES) + 2))
   350  
   351  		session2 := podmanTest.Podman([]string{"images", "--all"})
   352  		session2.WaitWithDefaultTimeout()
   353  		Expect(session2).Should(ExitCleanly())
   354  		Expect(session2.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES) + 4))
   355  	})
   356  
   357  	It("podman images filter by label", func() {
   358  		dockerfile := `FROM quay.io/libpod/alpine:latest
   359  LABEL version="1.0"
   360  LABEL "com.example.vendor"="Example Vendor"
   361  `
   362  		podmanTest.BuildImage(dockerfile, "test", "true")
   363  		session := podmanTest.Podman([]string{"images", "-f", "label=version=1.0"})
   364  		session.WaitWithDefaultTimeout()
   365  		Expect(session).Should(ExitCleanly())
   366  		Expect(session.OutputToStringArray()).To(HaveLen(2))
   367  	})
   368  
   369  	It("podman with images with no layers", func() {
   370  		dockerfile := strings.Join([]string{
   371  			`FROM scratch`,
   372  			`LABEL org.opencontainers.image.authors="<somefolks@example.org>"`,
   373  			`LABEL org.opencontainers.image.created=2019-06-11T19:03:37Z`,
   374  			`LABEL org.opencontainers.image.description="This is a test image"`,
   375  			`LABEL org.opencontainers.image.title=test`,
   376  			`LABEL org.opencontainers.image.vendor="Example.org"`,
   377  			`LABEL org.opencontainers.image.version=1`,
   378  		}, "\n")
   379  		podmanTest.BuildImage(dockerfile, "foo", "true")
   380  
   381  		session := podmanTest.Podman([]string{"images", "foo"})
   382  		session.WaitWithDefaultTimeout()
   383  		Expect(session).Should(ExitCleanly())
   384  		output := session.OutputToString()
   385  		Expect(output).To(Not(MatchRegexp("<missing>")))
   386  		Expect(output).To(Not(MatchRegexp("error")))
   387  
   388  		session = podmanTest.Podman([]string{"image", "tree", "foo"})
   389  		session.WaitWithDefaultTimeout()
   390  		Expect(session).Should(ExitCleanly())
   391  		output = session.OutputToString()
   392  		Expect(output).To(MatchRegexp("No Image Layers"))
   393  
   394  		session = podmanTest.Podman([]string{"history", "foo"})
   395  		session.WaitWithDefaultTimeout()
   396  		Expect(session).Should(ExitCleanly())
   397  		output = session.OutputToString()
   398  		Expect(output).To(Not(MatchRegexp("error")))
   399  
   400  		session = podmanTest.Podman([]string{"history", "--quiet", "foo"})
   401  		session.WaitWithDefaultTimeout()
   402  		Expect(session).Should(ExitCleanly())
   403  		Expect(session.OutputToStringArray()).To(HaveLen(6))
   404  
   405  		session = podmanTest.Podman([]string{"image", "list", "foo"})
   406  		session.WaitWithDefaultTimeout()
   407  		Expect(session).Should(ExitCleanly())
   408  		output = session.OutputToString()
   409  		Expect(output).To(Not(MatchRegexp("<missing>")))
   410  		Expect(output).To(Not(MatchRegexp("error")))
   411  
   412  		session = podmanTest.Podman([]string{"image", "list"})
   413  		session.WaitWithDefaultTimeout()
   414  		Expect(session).Should(ExitCleanly())
   415  		output = session.OutputToString()
   416  		Expect(output).To(Not(MatchRegexp("<missing>")))
   417  		Expect(output).To(Not(MatchRegexp("error")))
   418  
   419  		session = podmanTest.Podman([]string{"inspect", "foo"})
   420  		session.WaitWithDefaultTimeout()
   421  		Expect(session).Should(ExitCleanly())
   422  		output = session.OutputToString()
   423  		Expect(output).To(Not(MatchRegexp("<missing>")))
   424  		Expect(output).To(Not(MatchRegexp("error")))
   425  
   426  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "foo"})
   427  		session.WaitWithDefaultTimeout()
   428  		Expect(session).Should(ExitCleanly())
   429  		output = session.OutputToString()
   430  		Expect(output).To(Equal("[]"))
   431  	})
   432  
   433  	It("podman images --filter label=with,comma", func() {
   434  		dockerfile := `FROM quay.io/libpod/alpine:latest
   435  `
   436  		podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/before:latest", "false", "test=with,comma")
   437  		result := podmanTest.Podman([]string{"images", "--filter", "label=test=with,comma"})
   438  		result.WaitWithDefaultTimeout()
   439  		Expect(result).Should(ExitCleanly())
   440  		Expect(result.OutputToStringArray()).To(HaveLen(2))
   441  	})
   442  
   443  	It("podman images --filter readonly", func() {
   444  		dockerfile := `FROM quay.io/libpod/alpine:latest
   445  `
   446  		podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
   447  		result := podmanTest.Podman([]string{"images", "-f", "readonly=true"})
   448  		result.WaitWithDefaultTimeout()
   449  		Expect(result).Should(ExitCleanly())
   450  
   451  		result1 := podmanTest.Podman([]string{"images", "--filter", "readonly=false"})
   452  		result1.WaitWithDefaultTimeout()
   453  		Expect(result1).Should(ExitCleanly())
   454  		Expect(result.OutputToStringArray()).To(Not(Equal(result1.OutputToStringArray())))
   455  	})
   456  
   457  	It("podman image prune --filter", func() {
   458  		dockerfile := `FROM quay.io/libpod/alpine:latest
   459  RUN > file
   460  `
   461  		dockerfile2 := `FROM quay.io/libpod/alpine:latest
   462  RUN > file2
   463  `
   464  		podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/workdir:latest", "false", "abc")
   465  		podmanTest.BuildImageWithLabel(dockerfile2, "foobar.com/workdir:latest", "false", "xyz")
   466  		// --force used to avoid y/n question
   467  		result := podmanTest.Podman([]string{"image", "prune", "--filter", "label=abc", "--force"})
   468  		result.WaitWithDefaultTimeout()
   469  		Expect(result).Should(ExitCleanly())
   470  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   471  
   472  		// check if really abc is removed
   473  		result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
   474  		Expect(result.OutputToStringArray()).To(BeEmpty())
   475  
   476  	})
   477  
   478  	It("podman builder prune", func() {
   479  		dockerfile := `FROM quay.io/libpod/alpine:latest
   480  RUN > file
   481  `
   482  		dockerfile2 := `FROM quay.io/libpod/alpine:latest
   483  RUN > file2
   484  `
   485  		podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/workdir:latest", "false", "abc")
   486  		podmanTest.BuildImageWithLabel(dockerfile2, "foobar.com/workdir:latest", "false", "xyz")
   487  		// --force used to to avoid y/n question
   488  		result := podmanTest.Podman([]string{"builder", "prune", "--filter", "label=abc", "--force"})
   489  		result.WaitWithDefaultTimeout()
   490  		Expect(result).Should(ExitCleanly())
   491  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   492  
   493  		// check if really abc is removed
   494  		result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
   495  		Expect(result.OutputToStringArray()).To(BeEmpty())
   496  
   497  	})
   498  
   499  })