docker-py
docker-py copied to clipboard
Container.attrs["State"]["Running"] remains False after starting a container
After creating a Container object and starting it, the container's attrs
field still says the container is not running.
Only when creating a new Container object does the attrs
field show the correct status.
I wonder if any other fields of the attrs
attribute are affected?
Here is ascript demonstrating the problem:
import docker
from time import sleep
client = docker.from_env()
container = client.containers.create("nginx")
container.start()
sleep(5)
print(container.attrs["State"]["Running"]) # prints False
print(client.containers.get(container.id).attrs["State"]["Running"]) # prints True