Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
Getting docker stats programmatically

I am using docker-py and trying to get docker stats. But I am unable to get any API for returning stats for particular container. Is there a REST API or any other way to programmatically get the stats ?

>>> cli = docker.Client(base_url="tcp://xxxxx:2375", version='1.21')
>>> cli.containers() >> gives the right o/p
>>> cli.containers.get()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'get'

>>> docker.version
'1.10.6'
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You may be looking for Container.stats.

about 4 years ago · Santiago Trujillo Report

0

  1. Get stats for a particular container name example: "monitoring-tinydb". Note: change this container name with your desired container id or name.

    import docker
    client = docker.from_env()
    container = client.containers.get("monitoring-tinydb")
    status = container.stats(decode=None, stream = False)
    print(status)
    
    
  2. Get stats for all containers running in the docker host

    import docker
    client = docker.DockerClient(base_url='unix:///var/run/docker.sock')
    for containers in client.containers.list():
        print(containers.stats(decode=None, stream = False))
    
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!