diff --git a/docs/source/markdown/podman-container-inspect.1.md.in b/docs/source/markdown/podman-container-inspect.1.md.in index b6cd589a44..79ed090781 100644 --- a/docs/source/markdown/podman-container-inspect.1.md.in +++ b/docs/source/markdown/podman-container-inspect.1.md.in @@ -40,7 +40,9 @@ Valid placeholders for the Go template are listed below: | .Image | Container image ID (64-char hash) | | .ImageDigest | Container image digest (sha256:+64-char hash) | | .ImageName | Container image name (string) | +| .InitContainerType | Type of init container if applicable (string) | | .IsInfra | Is this an infra container? (string: true/false) | +| .IsInitCtr | Is this an init container? (string: true/false) | | .IsService | Is this a service container? (string: true/false) | | .KubeExitCodePropagation | Kube exit-code propagation (string) | | .LockNumber | Number of the container's Libpod lock | diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 8a48d3faea..c9c1f6d06e 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -168,6 +168,8 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver Dependencies: c.Dependencies(), IsInfra: c.IsInfra(), IsService: c.IsService(), + IsInitCtr: c.IsInitCtr(), + InitContainerType: c.config.InitContainerType, KubeExitCodePropagation: config.KubeExitCodePropagation.String(), LockNumber: c.lock.ID(), UseImageHosts: c.config.UseImageHosts, diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go index 86f76d82b0..9b1984feb7 100644 --- a/libpod/define/container_inspect.go +++ b/libpod/define/container_inspect.go @@ -807,6 +807,8 @@ type InspectContainerData struct { Namespace string `json:"Namespace"` IsInfra bool `json:"IsInfra"` IsService bool `json:"IsService"` + IsInitCtr bool `json:"IsInitCtr"` + InitContainerType string `json:"InitContainerType,omitempty"` KubeExitCodePropagation string `json:"KubeExitCodePropagation"` LockNumber uint32 `json:"lockNumber"` Config *InspectContainerConfig `json:"Config"` diff --git a/test/e2e/container_inspect_test.go b/test/e2e/container_inspect_test.go index 7894d4a87a..4b4e3133ae 100644 --- a/test/e2e/container_inspect_test.go +++ b/test/e2e/container_inspect_test.go @@ -141,6 +141,28 @@ var _ = Describe("Podman container inspect", func() { Expect(data[0].Config.Env).To(ContainElement(Equal(secretName + "=*******"))) }) + It("podman inspect identifies init container", func() { + podName := "test-init-pod" + initCtrName := "test-init-ctr" + normalCtrName := "test-normal-ctr" + + podmanTest.PodmanExitCleanly("pod", "create", "--name", podName) + + podmanTest.PodmanExitCleanly("create", "--pod", podName, "--init-ctr=always", "--name", initCtrName, ALPINE, "echo", "init") + + podmanTest.PodmanExitCleanly("create", "--pod", podName, "--name", normalCtrName, ALPINE, "top") + + initData := podmanTest.InspectContainer(initCtrName) + Expect(initData).To(HaveLen(1)) + Expect(initData[0].IsInitCtr).To(BeTrue()) + Expect(initData[0].InitContainerType).To(Equal("always")) + + normalData := podmanTest.InspectContainer(normalCtrName) + Expect(normalData).To(HaveLen(1)) + Expect(normalData[0].IsInitCtr).To(BeFalse()) + Expect(normalData[0].InitContainerType).To(BeEmpty()) + }) + It("podman inspect NetworkSettings DNSNames and Aliases", func() { netName := "dnstest" session := podmanTest.Podman([]string{"network", "create", netName})