Closed
Description
Is it intentional that the following methods to get container.attrs
have different results?
containers = client.containers.list()
for container in containers:
# The output of the line below is relatively short. More importantly, attrs["State"] is a string (e.x. "running")
partial_attrs = container.attrs
# The following returns the full attributes of a container. attrs["State"] is a dictionary, where attrs["State"]["Status] is a string (i.e. "running)
container_id = container.id
attrs = client.containers.get(container_id).attrs
This was discovered when debugging why container.status
yeilds string indices must be integers, not 'str'
.
# container.status throws Type error -- likely since `container.attrs` gives
# a different value than `client.containers.get(<id>).attrs`
attrs =client.containers.get(container_id).attrs
state: dict[str | int | bool] = attrs.get("State", {})
status = state.get("Status", "")
Has the issue with container.status
been resolved?
#446
Note
Podman version = 5.4.2
> podman --vesion
podman version 5.4.2
Podman Python version 5.2.0
> pip show podman
Name: podman
Version: 5.2.0
Summary: Bindings for Podman RESTful API
Home-page: https://github.com/containers/podman-py
Author: Brent Baude, Jhon Honce, Urvashi Mohnani, Nicola Sella
Author-email: jhonce@redhat.com
License: Apache-2.0
Location: c:\users\...\python\python310\site-packages
Requires: requests, tomli, urllib3
Required-by:
Metadata
Metadata
Assignees
Labels
No labels