docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Container.attrs["State"]["Running"] remains False after starting a container

Open emendir opened this issue 8 months ago • 1 comments

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

emendir avatar Jun 06 '24 06:06 emendir