Docker stats questions

@crosbymichael thanks heaps for adding docker stats. I had some questions about the CLI side of things.

Are there any plans for a version that can be consumed out of TTY, eg just give you a single line and exit?

Are there any plans to make docker stats work without any params and simply display full stats for all containers?

As for the CLI consuming one line and exiting I don’t have any plans for it. It was meant to be a simple way to quickly view stats for some containers, if you need more information or better control, hitting the API is your best bet because it provides much more information.

A single API endpoint for all container could be cool. If you feel like trying to contribute this go ahead :wink:

I definitely think having docker stats by its lonesome work in a similar way to htop would be super awesome, even if there are no plans for a non refreshing cli version.

I will have a look at doing a docker PR but it may take a bit, will consume the API for now.

Thanks heaps, it is a very useful feature.

Quick one,

In the context of multiple CPUs and processes, what does the CPU percent mean? Can it go above 100%?

(note this is possible even in a single app per container setting, for example postgres will fork per connection)

Yes, it can go over 100% if multiple cores are used.

thanks, when I was looking at the PR

https://github.com/docker/docker/blob/master/api/client/commands.go#L2758-L2771

It seems to be scaling it according to the number of CPUs its reporting, I wonder if this accounts for situations where the container is only allowed to work on 4/8 cpus

I did implement monitoring at:

The API seemed pretty straight forward though deciphering the meaning of the numbers was a bit rough cause I had to dig in to the source to figure it out, API docks are a bit thin.

Hardest thing was consuming the API in a non streaming way, it forced a pretty rough pattern and I worry that if there is a bug somewhere I am going to leak connections. I think a non-streaming option would be very helpful.