mirror of
https://github.com/containers/podman.git
synced 2026-03-26 02:24:02 -04:00
Merge pull request #28121 from pkoenig10/filterStatus
List all status values in status filter documentation
This commit is contained in:
@@ -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 |
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user