Skip to content
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

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

Closed
emendir opened this issue Jun 6, 2024 · 1 comment
Closed

Comments

@emendir
Copy link

emendir commented Jun 6, 2024

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
@massi1008
Copy link

This is intended behaviour, see the docs: https://docker-py.readthedocs.io/en/stable/containers.html#container-objects

Note that local attributes are cached; users may call reload() to query the Docker daemon for the current properties, causing attrs to be refreshed.

@emendir emendir closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants