From 0d7f00b4c00f0ca2e6059c0685566d147dc60516 Mon Sep 17 00:00:00 2001 From: Patrick Koenig Date: Wed, 18 Feb 2026 22:52:36 -0500 Subject: [PATCH] List all status values in status filter documentation Signed-off-by: Patrick Koenig --- .../markdown/options/filter.container.md | 36 +++++++++---------- libpod/define/containerstate.go | 2 ++ pkg/domain/filters/containers.go | 15 +++----- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/docs/source/markdown/options/filter.container.md b/docs/source/markdown/options/filter.container.md index aa89e8c17c..e578bacfa5 100644 --- a/docs/source/markdown/options/filter.container.md +++ b/docs/source/markdown/options/filter.container.md @@ -11,22 +11,22 @@ Filters with the same key work inclusive with the only exception being Valid filters are listed below: -| **Filter** | **Description** | -|------------|-------------------------------------------------------------------------------------------------| -| id | [ID] Container's ID (CID prefix match by default; accepts regex) | -| name | [Name] Container's name (accepts regex) | -| label | [Key] or [Key=Value] Label assigned to a container | -| label! | [Key] or [Key=Value] Label NOT assigned to a container | -| exited | [Int] Container's exit code | -| status | [Status] Container's status: 'created', 'initialized', 'exited', 'paused', 'running', 'unknown' | -| ancestor | [ImageName] Image or descendant used to create container (accepts regex) | -| before | [ID] or [Name] Containers created before this container | -| since | [ID] or [Name] Containers created since this container | -| volume | [VolumeName] or [MountpointDestination] Volume mounted in container | -| health | [Status] healthy or unhealthy | -| pod | [Pod] name or full or partial ID of pod | -| network | [Network] name or full ID of network | -| restart-policy | [Policy] Container's restart policy (e.g., 'no', 'on-failure', 'always', 'unless-stopped') | -| until | [DateTime] Containers created before the given duration or time. | -| command | [Command] the command the container is executing, only argv[0] is taken | +| **Filter** | **Description** | +|----------------------|-------------------------------------------------------------------------------------------------| +| id | [ID] Container's ID (CID prefix match by default; accepts regex) | +| name | [Name] Container's name (accepts regex) | +| label | [Key] or [Key=Value] Label assigned to a container | +| label! | [Key] or [Key=Value] Label NOT assigned to a container | +| exited | [Int] Container's exit code | +| status | [Status] Container's status: 'created', 'initialized', 'running', 'stopped', 'paused', 'exited', 'removing', 'stopping', 'unknown' | +| ancestor | [ImageName] Image or descendant used to create container (accepts regex) | +| before | [ID] or [Name] Containers created before this container | +| since | [ID] or [Name] Containers created since this container | +| volume | [VolumeName] or [MountpointDestination] Volume mounted in container | +| health | [Status] healthy or unhealthy | +| pod | [Pod] name or full or partial ID of pod | +| network | [Network] name or full ID of network | +| restart-policy | [Policy] Container's restart policy (e.g., 'no', 'on-failure', 'always', 'unless-stopped') | +| until | [DateTime] Containers created before the given duration or time. | +| command | [Command] the command the container is executing, only argv[0] is taken | | should-start-on-boot | [Bool] Containers that need to be restarted after system reboot. True for containers with restart policy 'always', or 'unless-stopped' that were not explicitly stopped by the user | diff --git a/libpod/define/containerstate.go b/libpod/define/containerstate.go index a766010007..e04fc6ae99 100644 --- a/libpod/define/containerstate.go +++ b/libpod/define/containerstate.go @@ -89,6 +89,8 @@ func StringToContainerStatus(status string) (ContainerStatus, error) { return ContainerStateExited, nil case ContainerStateRemoving.String(): return ContainerStateRemoving, nil + case ContainerStateStopping.String(): + return ContainerStateStopping, nil default: return ContainerStateUnknown, fmt.Errorf("unknown container state: %s: %w", status, ErrInvalidArg) } diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index fba8896df2..058b5a2726 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -73,10 +73,7 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo return false } state := status.String() - switch status { - case define.ContainerStateConfigured: - state = "created" - case define.ContainerStateStopped: + if status == define.ContainerStateStopped { state = "exited" } for _, filterValue := range filterValues { @@ -446,17 +443,15 @@ func GenerateExternalContainerFilterFuncs(filter string, filterValues []string, } } return func(listContainer *types.ListContainer) bool { - status := listContainer.State - if status == define.ContainerStateConfigured.String() { - status = "created" - } else if status == define.ContainerStateStopped.String() { - status = "exited" + state := listContainer.State + if state == define.ContainerStateStopped.String() { + state = "exited" } for _, filterValue := range filterValues { if filterValue == "stopped" { filterValue = "exited" } - if status == filterValue { + if state == filterValue { return true } }