docker python cli get stats code example
Example: python docker stats
import docker
import multiprocessing as mp
output = mp.Queue()
def stats(server):
client=docker.from_env()
client_lowlevel = docker.APIClient(base_url='unix://var/run/docker.sock')
client_stats=client_lowlevel.stats(container=server,decode=True, stream=False)
output.put(client_stats)
processes =[ mp.Process(target=stats, args=(server)) for server in ['server1','server2']]
for p in processes:
p.start()
for p in processes:
p.join()