containers.list(all=True) does not return the result while any containers in the list are stopping/starting/restarting.
It waits until stopping/starting/restarting of containers is done, which makes the code blocking.
The equivalent docker command 'docker ps -a' shows result in real-time even containers are in transition.
The similar situation I met, sometimes the containers.list blocks all my operations! OMG
@shin-
The similar situation I met, it just blocks like frozen.
I'm guessing this is due to list() being greedy and calling inspect on each container, which might block while the container is in a transitive state. Are you seeing the same issue with client.api.containers(all=True)?
We could probably add an option to list() to create Container objects based solely on the partial information provided by the /containers endpoint and let users call reload() explicitly to retrieve the complete attribute set.
Awosome! You are right, thanks for your advice, the low-level api client.api.containers(all=True) is Similar to the docker ps command . It looks like never frozen.
Maybe, is there the same situation as client.images.list? I guess.
client.api.containers(all=True) worked fine as shin- suggested. But it would be nice if the option to create Container objects with limited information without blocking is available.
Fixed by #1955
Most helpful comment
I'm guessing this is due to
list()being greedy and callinginspecton each container, which might block while the container is in a transitive state. Are you seeing the same issue withclient.api.containers(all=True)?We could probably add an option to
list()to createContainerobjects based solely on the partial information provided by the/containersendpoint and let users callreload()explicitly to retrieve the complete attribute set.