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

     1  package integration
     2  
     3  import (
     4  	. "github.com/containers/podman/v4/test/utils"
     5  	. "github.com/onsi/ginkgo/v2"
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gexec"
     8  	"github.com/opencontainers/selinux/go-selinux"
     9  )
    10  
    11  var _ = Describe("Podman inspect", func() {
    12  
    13  	It("podman inspect alpine image", func() {
    14  		session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
    15  		session.WaitWithDefaultTimeout()
    16  		Expect(session).Should(ExitCleanly())
    17  		Expect(session.OutputToString()).To(BeValidJSON())
    18  		imageData := session.InspectImageJSON()
    19  		Expect(imageData[0].RepoTags[0]).To(Equal("quay.io/libpod/alpine:latest"))
    20  	})
    21  
    22  	It("podman inspect bogus container", func() {
    23  		session := podmanTest.Podman([]string{"inspect", "foobar4321"})
    24  		session.WaitWithDefaultTimeout()
    25  		Expect(session).To(ExitWithError())
    26  	})
    27  
    28  	It("podman inspect filter should work if result contains tab", func() {
    29  		session := podmanTest.Podman([]string{"build", "--tag", "envwithtab", "build/envwithtab"})
    30  		session.WaitWithDefaultTimeout()
    31  		Expect(session).Should(ExitCleanly())
    32  
    33  		// Verify that OS and Arch are being set
    34  		inspect := podmanTest.Podman([]string{"inspect", "-f", "{{ .Config.Env }}", "envwithtab"})
    35  		inspect.WaitWithDefaultTimeout()
    36  		Expect(inspect).Should(ExitCleanly())
    37  		// output should not be empty
    38  		// test validates fix for https://github.com/containers/podman/issues/8785
    39  		Expect(inspect.OutputToString()).To(ContainSubstring("TEST="), ".Config.Env")
    40  
    41  		session = podmanTest.Podman([]string{"rmi", "envwithtab"})
    42  		session.WaitWithDefaultTimeout()
    43  		Expect(session).Should(ExitCleanly())
    44  	})
    45  
    46  	It("podman inspect with GO format", func() {
    47  		session := podmanTest.Podman([]string{"inspect", "--format", "{{.ID}}", ALPINE})
    48  		session.WaitWithDefaultTimeout()
    49  		Expect(session).Should(ExitCleanly())
    50  
    51  		result := podmanTest.Podman([]string{"images", "-q", "--no-trunc", ALPINE})
    52  		result.WaitWithDefaultTimeout()
    53  		Expect(session).Should(ExitCleanly())
    54  		Expect(result.OutputToStringArray()).To(ContainElement("sha256:"+session.OutputToString()), "'podman images -q --no-truncate' includes 'podman inspect --format .ID'")
    55  	})
    56  
    57  	It("podman inspect specified type", func() {
    58  		session := podmanTest.Podman([]string{"inspect", "--type", "image", ALPINE})
    59  		session.WaitWithDefaultTimeout()
    60  		Expect(session).Should(ExitCleanly())
    61  	})
    62  
    63  	It("podman inspect container with GO format for ConmonPidFile", func() {
    64  		session, ec, _ := podmanTest.RunLsContainer("test1")
    65  		session.WaitWithDefaultTimeout()
    66  		Expect(ec).To(Equal(0))
    67  
    68  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.ConmonPidFile}}", "test1"})
    69  		session.WaitWithDefaultTimeout()
    70  		Expect(session).Should(ExitCleanly())
    71  	})
    72  
    73  	It("podman inspect container with size", func() {
    74  		session, ec, _ := podmanTest.RunLsContainer("sizetest")
    75  		session.WaitWithDefaultTimeout()
    76  		Expect(ec).To(Equal(0))
    77  
    78  		result := podmanTest.Podman([]string{"inspect", "--size", "sizetest"})
    79  		result.WaitWithDefaultTimeout()
    80  		Expect(result).Should(ExitCleanly())
    81  		conData := result.InspectContainerToJSON()
    82  		Expect(conData[0].SizeRootFs).To(BeNumerically(">", 0))
    83  		Expect(*conData[0].SizeRw).To(BeNumerically(">=", 0))
    84  	})
    85  
    86  	It("podman inspect container and image", func() {
    87  		ls, ec, _ := podmanTest.RunLsContainer("")
    88  		ls.WaitWithDefaultTimeout()
    89  		Expect(ec).To(Equal(0))
    90  		cid := ls.OutputToString()
    91  
    92  		result := podmanTest.Podman([]string{"inspect", "--format={{.ID}}", cid, ALPINE})
    93  		result.WaitWithDefaultTimeout()
    94  		Expect(result).Should(ExitCleanly())
    95  		Expect(result.OutputToStringArray()).To(HaveLen(2))
    96  	})
    97  
    98  	It("podman inspect container and filter for Image{ID}", func() {
    99  		ls, ec, _ := podmanTest.RunLsContainer("")
   100  		ls.WaitWithDefaultTimeout()
   101  		Expect(ec).To(Equal(0))
   102  		cid := ls.OutputToString()
   103  
   104  		result := podmanTest.Podman([]string{"inspect", "--format={{.ImageID}}", cid})
   105  		result.WaitWithDefaultTimeout()
   106  		Expect(result).Should(ExitCleanly())
   107  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   108  
   109  		result = podmanTest.Podman([]string{"inspect", "--format={{.Image}}", cid})
   110  		result.WaitWithDefaultTimeout()
   111  		Expect(result).Should(ExitCleanly())
   112  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   113  	})
   114  
   115  	It("podman inspect container and filter for CreateCommand", func() {
   116  		ls, ec, _ := podmanTest.RunLsContainer("")
   117  		ls.WaitWithDefaultTimeout()
   118  		Expect(ec).To(Equal(0))
   119  		cid := ls.OutputToString()
   120  
   121  		result := podmanTest.Podman([]string{"inspect", "--format={{.Config.CreateCommand}}", cid})
   122  		result.WaitWithDefaultTimeout()
   123  		Expect(result).Should(ExitCleanly())
   124  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   125  	})
   126  
   127  	It("podman inspect -l with additional input should fail", func() {
   128  		SkipIfRemote("--latest flag n/a")
   129  		result := podmanTest.Podman([]string{"inspect", "-l", "1234foobar"})
   130  		result.WaitWithDefaultTimeout()
   131  		Expect(result).Should(Exit(125))
   132  	})
   133  
   134  	It("podman inspect with mount filters", func() {
   135  
   136  		ctrSession := podmanTest.Podman([]string{"create", "--name", "test", "-v", "/tmp:/test1", ALPINE, "top"})
   137  		ctrSession.WaitWithDefaultTimeout()
   138  		Expect(ctrSession).Should(ExitCleanly())
   139  
   140  		inspectSource := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Source}}"})
   141  		inspectSource.WaitWithDefaultTimeout()
   142  		Expect(inspectSource).Should(ExitCleanly())
   143  		Expect(inspectSource.OutputToString()).To(Equal("/tmp"))
   144  
   145  		inspectSrc := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Src}}"})
   146  		inspectSrc.WaitWithDefaultTimeout()
   147  		Expect(inspectSrc).Should(ExitCleanly())
   148  		Expect(inspectSrc.OutputToString()).To(Equal("/tmp"))
   149  
   150  		inspectDestination := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Destination}}"})
   151  		inspectDestination.WaitWithDefaultTimeout()
   152  		Expect(inspectDestination).Should(ExitCleanly())
   153  		Expect(inspectDestination.OutputToString()).To(Equal("/test1"))
   154  
   155  		inspectDst := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Dst}}"})
   156  		inspectDst.WaitWithDefaultTimeout()
   157  		Expect(inspectDst).Should(ExitCleanly())
   158  		Expect(inspectDst.OutputToString()).To(Equal("/test1"))
   159  	})
   160  
   161  	It("podman inspect shows healthcheck on docker image", func() {
   162  		podmanTest.AddImageToRWStore(HEALTHCHECK_IMAGE)
   163  		session := podmanTest.Podman([]string{"inspect", "--format=json", HEALTHCHECK_IMAGE})
   164  		session.WaitWithDefaultTimeout()
   165  		imageData := session.InspectImageJSON()
   166  		Expect(imageData[0].HealthCheck.Timeout).To(BeNumerically("==", 3000000000))
   167  		Expect(imageData[0].HealthCheck.Interval).To(BeNumerically("==", 60000000000))
   168  		Expect(imageData[0].HealthCheck).To(HaveField("Test", []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"}))
   169  	})
   170  
   171  	It("podman inspect --latest with no container fails", func() {
   172  		SkipIfRemote("testing --latest flag")
   173  
   174  		session := podmanTest.Podman([]string{"inspect", "--latest"})
   175  		session.WaitWithDefaultTimeout()
   176  		Expect(session).To(ExitWithError())
   177  	})
   178  
   179  	It("podman [image,container] inspect on image", func() {
   180  		baseInspect := podmanTest.Podman([]string{"inspect", ALPINE})
   181  		baseInspect.WaitWithDefaultTimeout()
   182  		Expect(baseInspect).Should(ExitCleanly())
   183  		baseJSON := baseInspect.InspectImageJSON()
   184  		Expect(baseJSON).To(HaveLen(1))
   185  
   186  		ctrInspect := podmanTest.Podman([]string{"container", "inspect", ALPINE})
   187  		ctrInspect.WaitWithDefaultTimeout()
   188  		Expect(ctrInspect).To(ExitWithError())
   189  
   190  		imageInspect := podmanTest.Podman([]string{"image", "inspect", ALPINE})
   191  		imageInspect.WaitWithDefaultTimeout()
   192  		Expect(imageInspect).Should(ExitCleanly())
   193  		imageJSON := imageInspect.InspectImageJSON()
   194  		Expect(imageJSON).To(HaveLen(1))
   195  
   196  		Expect(baseJSON[0]).To(HaveField("ID", imageJSON[0].ID))
   197  	})
   198  
   199  	It("podman [image, container] inspect on container", func() {
   200  		ctrName := "testCtr"
   201  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
   202  		create.WaitWithDefaultTimeout()
   203  		Expect(create).Should(ExitCleanly())
   204  
   205  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
   206  		baseInspect.WaitWithDefaultTimeout()
   207  		Expect(baseInspect).Should(ExitCleanly())
   208  		baseJSON := baseInspect.InspectContainerToJSON()
   209  		Expect(baseJSON).To(HaveLen(1))
   210  
   211  		ctrInspect := podmanTest.Podman([]string{"container", "inspect", ctrName})
   212  		ctrInspect.WaitWithDefaultTimeout()
   213  		Expect(ctrInspect).Should(ExitCleanly())
   214  		ctrJSON := ctrInspect.InspectContainerToJSON()
   215  		Expect(ctrJSON).To(HaveLen(1))
   216  
   217  		imageInspect := podmanTest.Podman([]string{"image", "inspect", ctrName})
   218  		imageInspect.WaitWithDefaultTimeout()
   219  		Expect(imageInspect).To(ExitWithError())
   220  
   221  		Expect(baseJSON[0]).To(HaveField("ID", ctrJSON[0].ID))
   222  	})
   223  
   224  	It("podman inspect always produces a valid array", func() {
   225  		baseInspect := podmanTest.Podman([]string{"inspect", "doesNotExist"})
   226  		baseInspect.WaitWithDefaultTimeout()
   227  		Expect(baseInspect).To(ExitWithError())
   228  		emptyJSON := baseInspect.InspectContainerToJSON()
   229  		Expect(emptyJSON).To(BeEmpty())
   230  	})
   231  
   232  	It("podman inspect one container with not exist returns 1-length valid array", func() {
   233  		ctrName := "testCtr"
   234  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
   235  		create.WaitWithDefaultTimeout()
   236  		Expect(create).Should(ExitCleanly())
   237  
   238  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName, "doesNotExist"})
   239  		baseInspect.WaitWithDefaultTimeout()
   240  		Expect(baseInspect).To(ExitWithError())
   241  		baseJSON := baseInspect.InspectContainerToJSON()
   242  		Expect(baseJSON).To(HaveLen(1))
   243  		Expect(baseJSON[0]).To(HaveField("Name", ctrName))
   244  	})
   245  
   246  	It("podman inspect container + image with same name gives container", func() {
   247  		podmanTest.AddImageToRWStore(ALPINE)
   248  		ctrName := "testcontainer"
   249  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
   250  		create.WaitWithDefaultTimeout()
   251  		Expect(create).Should(ExitCleanly())
   252  
   253  		tag := podmanTest.Podman([]string{"tag", ALPINE, ctrName + ":latest"})
   254  		tag.WaitWithDefaultTimeout()
   255  		Expect(tag).Should(ExitCleanly())
   256  
   257  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
   258  		baseInspect.WaitWithDefaultTimeout()
   259  		Expect(baseInspect).Should(ExitCleanly())
   260  		baseJSON := baseInspect.InspectContainerToJSON()
   261  		Expect(baseJSON).To(HaveLen(1))
   262  		Expect(baseJSON[0]).To(HaveField("Name", ctrName))
   263  	})
   264  
   265  	It("podman inspect - HostConfig.SecurityOpt ", func() {
   266  		if !selinux.GetEnabled() {
   267  			Skip("SELinux not enabled")
   268  		}
   269  
   270  		ctrName := "hugo"
   271  		create := podmanTest.Podman([]string{
   272  			"create", "--name", ctrName,
   273  			"--security-opt", "seccomp=unconfined",
   274  			"--security-opt", "label=type:spc_t",
   275  			"--security-opt", "label=level:s0",
   276  			ALPINE, "sh"})
   277  
   278  		create.WaitWithDefaultTimeout()
   279  		Expect(create).Should(ExitCleanly())
   280  
   281  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
   282  		baseInspect.WaitWithDefaultTimeout()
   283  		Expect(baseInspect).Should(ExitCleanly())
   284  		baseJSON := baseInspect.InspectContainerToJSON()
   285  		Expect(baseJSON).To(HaveLen(1))
   286  		Expect(baseJSON[0].HostConfig).To(HaveField("SecurityOpt", []string{"label=type:spc_t,label=level:s0", "seccomp=unconfined"}))
   287  	})
   288  
   289  	It("podman inspect pod", func() {
   290  		podName := "testpod"
   291  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   292  		create.WaitWithDefaultTimeout()
   293  		Expect(create).Should(ExitCleanly())
   294  
   295  		inspect := podmanTest.Podman([]string{"inspect", podName})
   296  		inspect.WaitWithDefaultTimeout()
   297  		Expect(inspect).Should(ExitCleanly())
   298  		Expect(inspect.OutputToString()).To(BeValidJSON())
   299  		podData := inspect.InspectPodArrToJSON()
   300  		Expect(podData[0]).To(HaveField("Name", podName))
   301  	})
   302  
   303  	It("podman inspect pod with type", func() {
   304  		podName := "testpod"
   305  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   306  		create.WaitWithDefaultTimeout()
   307  		Expect(create).Should(ExitCleanly())
   308  
   309  		inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
   310  		inspect.WaitWithDefaultTimeout()
   311  		Expect(inspect).Should(ExitCleanly())
   312  		Expect(inspect.OutputToString()).To(BeValidJSON())
   313  		podData := inspect.InspectPodArrToJSON()
   314  		Expect(podData[0]).To(HaveField("Name", podName))
   315  	})
   316  
   317  	It("podman inspect latest pod", func() {
   318  		SkipIfRemote("--latest flag n/a")
   319  		podName := "testpod"
   320  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   321  		create.WaitWithDefaultTimeout()
   322  		Expect(create).Should(ExitCleanly())
   323  
   324  		inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", "--latest"})
   325  		inspect.WaitWithDefaultTimeout()
   326  		Expect(inspect).Should(ExitCleanly())
   327  		Expect(inspect.OutputToString()).To(BeValidJSON())
   328  		podData := inspect.InspectPodArrToJSON()
   329  		Expect(podData[0]).To(HaveField("Name", podName))
   330  	})
   331  	It("podman inspect latest defaults to latest container", func() {
   332  		SkipIfRemote("--latest flag n/a")
   333  		podName := "testpod"
   334  		pod := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   335  		pod.WaitWithDefaultTimeout()
   336  		Expect(pod).Should(ExitCleanly())
   337  
   338  		inspect1 := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
   339  		inspect1.WaitWithDefaultTimeout()
   340  		Expect(inspect1).Should(ExitCleanly())
   341  		Expect(inspect1.OutputToString()).To(BeValidJSON())
   342  		podData := inspect1.InspectPodArrToJSON()
   343  		infra := podData[0].Containers[0].Name
   344  
   345  		inspect := podmanTest.Podman([]string{"inspect", "--latest"})
   346  		inspect.WaitWithDefaultTimeout()
   347  		Expect(inspect).Should(ExitCleanly())
   348  		Expect(inspect.OutputToString()).To(BeValidJSON())
   349  		containerData := inspect.InspectContainerToJSON()
   350  		Expect(containerData[0]).To(HaveField("Name", infra))
   351  	})
   352  
   353  	It("podman inspect network", func() {
   354  		name, path := generateNetworkConfig(podmanTest)
   355  		defer removeConf(path)
   356  
   357  		session := podmanTest.Podman([]string{"inspect", name, "--format", "{{.Driver}}"})
   358  		session.WaitWithDefaultTimeout()
   359  		Expect(session).Should(ExitCleanly())
   360  		Expect(session.OutputToString()).To(ContainSubstring("bridge"))
   361  	})
   362  
   363  	It("podman inspect a volume", func() {
   364  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
   365  		session.WaitWithDefaultTimeout()
   366  		volName := session.OutputToString()
   367  		Expect(session).Should(ExitCleanly())
   368  
   369  		session = podmanTest.Podman([]string{"inspect", volName})
   370  		session.WaitWithDefaultTimeout()
   371  		Expect(session).Should(ExitCleanly())
   372  		Expect(session.OutputToString()).To(BeValidJSON())
   373  	})
   374  
   375  	It("podman inspect a volume with --format", func() {
   376  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
   377  		session.WaitWithDefaultTimeout()
   378  		volName := session.OutputToString()
   379  		Expect(session).Should(ExitCleanly())
   380  
   381  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.Name}}", volName})
   382  		session.WaitWithDefaultTimeout()
   383  		Expect(session).Should(ExitCleanly())
   384  		Expect(session.OutputToString()).To(Equal(volName))
   385  	})
   386  	It("podman inspect --type container on a pod should fail", func() {
   387  		podName := "testpod"
   388  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   389  		create.WaitWithDefaultTimeout()
   390  		Expect(create).Should(ExitCleanly())
   391  
   392  		inspect := podmanTest.Podman([]string{"inspect", "--type", "container", podName})
   393  		inspect.WaitWithDefaultTimeout()
   394  		Expect(inspect).To(ExitWithError())
   395  	})
   396  
   397  	It("podman inspect --type network on a container should fail", func() {
   398  		ctrName := "testctr"
   399  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE})
   400  		create.WaitWithDefaultTimeout()
   401  		Expect(create).Should(ExitCleanly())
   402  
   403  		inspect := podmanTest.Podman([]string{"inspect", "--type", "network", ctrName})
   404  		inspect.WaitWithDefaultTimeout()
   405  		Expect(inspect).To(ExitWithError())
   406  	})
   407  
   408  	It("podman inspect --type pod on a container should fail", func() {
   409  		ctrName := "testctr"
   410  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE})
   411  		create.WaitWithDefaultTimeout()
   412  		Expect(create).Should(ExitCleanly())
   413  
   414  		inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", ctrName})
   415  		inspect.WaitWithDefaultTimeout()
   416  		Expect(inspect).To(ExitWithError())
   417  	})
   418  
   419  	It("podman inspect --type volume on a container should fail", func() {
   420  		ctrName := "testctr"
   421  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE})
   422  		create.WaitWithDefaultTimeout()
   423  		Expect(create).Should(ExitCleanly())
   424  
   425  		inspect := podmanTest.Podman([]string{"inspect", "--type", "volume", ctrName})
   426  		inspect.WaitWithDefaultTimeout()
   427  		Expect(inspect).To(ExitWithError())
   428  	})
   429  
   430  	// Fixes https://github.com/containers/podman/issues/8444
   431  	It("podman inspect --format json .NetworkSettings.Ports", func() {
   432  		ctnrName := "Ctnr_" + RandomString(25)
   433  
   434  		create := podmanTest.Podman([]string{"create", "--name", ctnrName, "-p", "8084:80", ALPINE})
   435  		create.WaitWithDefaultTimeout()
   436  		Expect(create).Should(ExitCleanly())
   437  
   438  		inspect := podmanTest.Podman([]string{"inspect", `--format="{{json .NetworkSettings.Ports}}"`, ctnrName})
   439  		inspect.WaitWithDefaultTimeout()
   440  		Expect(inspect).Should(ExitCleanly())
   441  		Expect(inspect.OutputToString()).To(Equal(`"{"80/tcp":[{"HostIp":"","HostPort":"8084"}]}"`))
   442  	})
   443  
   444  	It("Verify container inspect has default network", func() {
   445  		SkipIfRootless("Requires root CNI networking")
   446  		ctrName := "testctr"
   447  		session := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
   448  		session.WaitWithDefaultTimeout()
   449  		Expect(session).Should(ExitCleanly())
   450  
   451  		inspect := podmanTest.InspectContainer(ctrName)
   452  		Expect(inspect).To(HaveLen(1))
   453  		Expect(inspect[0].NetworkSettings.Networks).To(HaveLen(1))
   454  	})
   455  
   456  	It("Verify stopped container still has default network in inspect", func() {
   457  		SkipIfRootless("Requires root CNI networking")
   458  		ctrName := "testctr"
   459  		session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "top"})
   460  		session.WaitWithDefaultTimeout()
   461  		Expect(session).Should(ExitCleanly())
   462  
   463  		inspect := podmanTest.InspectContainer(ctrName)
   464  		Expect(inspect).To(HaveLen(1))
   465  		Expect(inspect[0].NetworkSettings.Networks).To(HaveLen(1))
   466  	})
   467  
   468  	It("Container inspect with unlimited ulimits should be -1", func() {
   469  		ctrName := "testctr"
   470  		session := podmanTest.Podman([]string{"run", "-d", "--ulimit", "core=-1:-1", "--name", ctrName, ALPINE, "top"})
   471  		session.WaitWithDefaultTimeout()
   472  		Expect(session).Should(ExitCleanly())
   473  
   474  		inspect := podmanTest.Podman([]string{"inspect", ctrName})
   475  		inspect.WaitWithDefaultTimeout()
   476  		Expect(inspect).Should(ExitCleanly())
   477  
   478  		data := inspect.InspectContainerToJSON()
   479  		ulimits := data[0].HostConfig.Ulimits
   480  		Expect(ulimits).ToNot(BeEmpty())
   481  		found := false
   482  		for _, ulimit := range ulimits {
   483  			if ulimit.Name == "RLIMIT_CORE" {
   484  				found = true
   485  				Expect(ulimit.Soft).To(BeNumerically("==", -1))
   486  				Expect(ulimit.Hard).To(BeNumerically("==", -1))
   487  			}
   488  		}
   489  		Expect(found).To(BeTrue(), "found RLIMIT_CORE")
   490  	})
   491  
   492  	It("Container inspect Ulimit test", func() {
   493  		SkipIfNotRootless("Only applicable to rootless")
   494  		ctrName := "testctr"
   495  		session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "top"})
   496  		session.WaitWithDefaultTimeout()
   497  		Expect(session).Should(ExitCleanly())
   498  
   499  		inspect := podmanTest.Podman([]string{"inspect", ctrName})
   500  		inspect.WaitWithDefaultTimeout()
   501  		Expect(inspect).Should(ExitCleanly())
   502  
   503  		dataCreate := inspect.InspectContainerToJSON()
   504  		ulimitsCreate := dataCreate[0].HostConfig.Ulimits
   505  		Expect(ulimitsCreate).To(BeEmpty())
   506  
   507  		start := podmanTest.Podman([]string{"start", ctrName})
   508  		start.WaitWithDefaultTimeout()
   509  		Expect(start).Should(ExitCleanly())
   510  
   511  		inspect2 := podmanTest.Podman([]string{"inspect", ctrName})
   512  		inspect2.WaitWithDefaultTimeout()
   513  		Expect(inspect2).Should(ExitCleanly())
   514  
   515  		dataStart := inspect2.InspectContainerToJSON()
   516  		ulimitsStart := dataStart[0].HostConfig.Ulimits
   517  		Expect(ulimitsStart).ToNot(BeEmpty())
   518  	})
   519  
   520  	It("Dropped capabilities are sorted", func() {
   521  		ctrName := "testCtr"
   522  		session := podmanTest.Podman([]string{"run", "-d", "--cap-drop", "SETUID", "--cap-drop", "SETGID", "--cap-drop", "CAP_NET_BIND_SERVICE", "--name", ctrName, ALPINE, "top"})
   523  		session.WaitWithDefaultTimeout()
   524  		Expect(session).Should(ExitCleanly())
   525  
   526  		inspect := podmanTest.Podman([]string{"inspect", ctrName})
   527  		inspect.WaitWithDefaultTimeout()
   528  		Expect(inspect).Should(ExitCleanly())
   529  
   530  		data := inspect.InspectContainerToJSON()
   531  		Expect(data).To(HaveLen(1))
   532  		Expect(data[0].HostConfig.CapDrop).To(HaveLen(3))
   533  		Expect(data[0].HostConfig.CapDrop[0]).To(Equal("CAP_NET_BIND_SERVICE"))
   534  		Expect(data[0].HostConfig.CapDrop[1]).To(Equal("CAP_SETGID"))
   535  		Expect(data[0].HostConfig.CapDrop[2]).To(Equal("CAP_SETUID"))
   536  	})
   537  
   538  	It("Add capabilities are sorted", func() {
   539  		ctrName := "testCtr"
   540  		session := podmanTest.Podman([]string{"run", "-d", "--cap-add", "SYS_ADMIN", "--cap-add", "CAP_NET_ADMIN", "--name", ctrName, ALPINE, "top"})
   541  		session.WaitWithDefaultTimeout()
   542  		Expect(session).Should(ExitCleanly())
   543  
   544  		inspect := podmanTest.Podman([]string{"inspect", ctrName})
   545  		inspect.WaitWithDefaultTimeout()
   546  		Expect(inspect).Should(ExitCleanly())
   547  
   548  		data := inspect.InspectContainerToJSON()
   549  		Expect(data).To(HaveLen(1))
   550  		Expect(data[0].HostConfig.CapAdd).To(HaveLen(2))
   551  		Expect(data[0].HostConfig.CapAdd[0]).To(Equal("CAP_NET_ADMIN"))
   552  		Expect(data[0].HostConfig.CapAdd[1]).To(Equal("CAP_SYS_ADMIN"))
   553  	})
   554  
   555  	It("podman inspect container with GO format for PidFile", func() {
   556  		SkipIfRemote("pidfile not handled by remote")
   557  		session, ec, _ := podmanTest.RunLsContainer("test1")
   558  		session.WaitWithDefaultTimeout()
   559  		Expect(ec).To(Equal(0))
   560  
   561  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.PidFile}}", "test1"})
   562  		session.WaitWithDefaultTimeout()
   563  		Expect(session).Should(ExitCleanly())
   564  	})
   565  
   566  	It("podman inspect container with bad create args", func() {
   567  		session := podmanTest.Podman([]string{"container", "create", ALPINE, "efcho", "Hello World"})
   568  		session.WaitWithDefaultTimeout()
   569  		Expect(session).Should(ExitCleanly())
   570  		cid := session.OutputToString()
   571  		session = podmanTest.Podman([]string{"container", "inspect", cid, "-f", "{{ .State.Error }}"})
   572  		session.WaitWithDefaultTimeout()
   573  		Expect(session).Should(ExitCleanly())
   574  		Expect(session.OutputToString()).To(BeEmpty())
   575  
   576  		session = podmanTest.Podman([]string{"start", cid})
   577  		session.WaitWithDefaultTimeout()
   578  		Expect(session).Should(Exit(125))
   579  		session = podmanTest.Podman([]string{"container", "inspect", cid, "-f", "'{{ .State.Error }}"})
   580  		session.WaitWithDefaultTimeout()
   581  		Expect(session).Should(ExitCleanly())
   582  		Expect(session.OutputToString()).ToNot(BeEmpty())
   583  	})
   584  
   585  })