-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
podman container ls --format="{{.State}}" returns the wrong information #18244
Comments
Thanks for reaching out, @mdhirt! Since you mention running on RHEL. If you desire a backport to RHEL, please reach out through the Red Hat customer channels. We can fix it upstream but downstream is up to the individual distributions/vendors. |
|
Thank you @Luap99 this provides exactly what I need. Should I close this issue now or is it still a bug that .State and .Status both return the output for .Status? |
I don't know, looking at the code history podman has this behavior at least since v2.0. So far nobody complained, changing the output now could break existing users that want the current output. Although we try to be docker compatible, if this works with docker it is a valid reason for us to change it. |
It works with Docker, so I think we should change it. |
I agree. |
@jwhonce do you recall any history on this one by chance? |
We should return the raw state string without any extra formatting in this case. `{{.Status}}` returns the nicely formatted string used in the default ps output, e.g. `Up 2 seconds ago`, while `{{.State}}` returns the state as string, e.g. `running`. This matches the docker output and allows better use in scripts. Fixes containers#18244 Signed-off-by: Paul Holzinger <[email protected]>
Podman version 4.1.1 on RedHat 8.5
Specifying a format to include container State in the output of podman container ls returns the value from the Status field and not the State field.
Actual Result.
podman container ls -a --format="{{json .Names}} {{json .State}} {{json .Status}}"
"test-container" "Up 3 weeks ago" "Up 3 weeks ago"
"stopped-container" "Exited (0) 16 Seconds ago" "Exited (0) 16 Seconds ago"
Expected Result.
podman container ls --format="{{json .Names}} {{json .State}} {{json .Status}}"
"test-container" "running" "Up 3 weeks ago"
"stopped-container" "exited" "Exited (0) 16 seconds ago"
Additional information.
Running podman container ls --format=json does display the correct state=value, however when scripting automated health checks it is useful to limit the returned values using the --filter="{{ }}" option.
podman container ls --format=json
[
{
...
"Names": [
"test-container"
],
...
"State": "running"
"Status": "Up 3 weeks ago"
...
},
{
...
"Names": [
"stopped-container"
],
...
"State": "exited"
"Status": "Exited (0) 16 seconds ago"
...
}
]
The text was updated successfully, but these errors were encountered: