Skip to content

Use docker-py or subprocess instead of unix socket to get containers stats #61

@antoineleclair

Description

@antoineleclair

url = f"http://localhost/containers/{container_id}/stats?stream=false"

Sometimes, for specific containers, this call hangs and eventually times out.

Using this seems to be working while the code in the link above hangs:

>>> import docker
>>> client = docker.from_env()
>>> container_id = "9484660d83fe7450e6686ed83103644611afaef0378beb021140601d1ce4c7ad"
>>> container = client.containers.get(container_id)
>>> stats = container.stats(stream=False)

Similarly, this does not hang:

docker stats --no-stream 9484660d83fe7450e6686ed83103644611afaef0378beb021140601d1ce4c7ad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions