Skip to content

Commit b02d752

Browse files
authored
Merge pull request #369 from yanxuean/show-pod-in-ps
support to show podid in crictl ps
2 parents 9d4dd73 + 2245fd3 commit b02d752

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/crictl/container.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
614614

615615
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
616616
if !opts.verbose && !opts.quiet {
617-
fmt.Fprintln(w, "CONTAINER ID\tIMAGE\tCREATED\tSTATE\tNAME\tATTEMPT")
617+
fmt.Fprintln(w, "CONTAINER ID\tIMAGE\tCREATED\tSTATE\tNAME\tATTEMPT\tPOD ID")
618618
}
619619
for _, c := range r.Containers {
620620
if opts.quiet {
@@ -635,8 +635,9 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
635635
image = getTruncatedID(digest.String(), string(digest.Algorithm())+":")
636636
}
637637
}
638-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%d\n",
639-
id, image, ctm, convertContainerState(c.State), c.Metadata.Name, c.Metadata.Attempt)
638+
PodID := getTruncatedID(c.PodSandboxId, "")
639+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%d\t%s\n",
640+
id, image, ctm, convertContainerState(c.State), c.Metadata.Name, c.Metadata.Attempt, PodID)
640641
continue
641642
}
642643

0 commit comments

Comments
 (0)