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