Add support for Names and ID in stats format#27797
Conversation
MHBauer
left a comment
There was a problem hiding this comment.
Code looks right. Not sure I understand the use case.
There was a problem hiding this comment.
Why here vs on the Stats struct? I don't have any preference. I'm just curious how we decide to put it on one or the other.
There was a problem hiding this comment.
Mainly because I wanted to keep Stats struct with only metrics field and no metadata.
There was a problem hiding this comment.
Check my understanding.
- Container has the user input name.
- Name has the full name, and used to have the user input name.
- ID has the full ID.
There was a problem hiding this comment.
yep, that's it. I kept Container as the user input as this is what it's doing now.
There was a problem hiding this comment.
Could you put ID at the top here? (ID, Name, Container)
There was a problem hiding this comment.
No reason to nit pick when its still in design review @thaJeztah. be nice to @vdemeester
There was a problem hiding this comment.
Why is this called Names with an s?
There was a problem hiding this comment.
@crosbymichael I asked myself the same question 😅. I did it to mimic the docker ps --format which has Names too, I'm fine to rename it to Name 👼
There was a problem hiding this comment.
@vdemeester docker ps used to show all the things a container could be referenced as which includes names, as well as link aliases. That's why it is plural.... it might still do that if you use --no-trunc come to think of it.
Definitely singular here is good.
There was a problem hiding this comment.
Can't we display both the container name and the container ID?
I believe the container name is more readable than its iD.
Thought? 😊
There was a problem hiding this comment.
@ripcurld00d On the debug log ? This change is here to keep the same behavior.
There was a problem hiding this comment.
@vdemeester yes, now I see it. s.Container can be the ID or the Name depends on what the user enters.
|
@vdemeester @thaJeztah |
|
If I'm not wrong, in case there is a container called Is that OK? Maybe adding |
|
@ripcurld00d yes you're right, I should update the description. For the name/id collision, I don't think we should do anything 👼. |
|
During review this PR, I found there would be an issue with EDIT: open an issue to track this #27937 |
e44cf35 to
7a1a9c5
Compare
|
@coolljt0725 yep, I'm not really sure how to fix it the best way possible 👼. At some point we should make it so that |
This adds support to display names or id of container instead of what was provided in the request. This keeps the default behavior (`docker stats byname` will display `byname` in the `CONTAINER` colmun and `docker stats byid` will display the id in the `CONTAINER` column) but adds two new format directive. Signed-off-by: Vincent Demeester <[email protected]>
7a1a9c5 to
ef915fd
Compare
|
What is the use case for this because adding three different ways have identifying the container is pretty confusing for me and hard to reason about that cons for this. |
|
@crosbymichael The use case is to be able to display the actual name or id of the container instead of the user input. Right now there is no way to get the name of a container for Keeping |
|
@vdemeester is this just an api issue or does the cli format have to change as well? Could we get away with just returning the full container id and not this name stuff since names can change and its weird. Most of the time the name will be the |
|
This shows merged into 1.13 milestone but it does not appear to be present in 17.03.0-ce. Also, shouldn't "byname" and "byid" be "--byname" and "--byid" since they are options? |
Add support for Names and ID in stats format
This adds support to display names or id of container instead of what was provided in the request.
This keeps the default behavior (
docker stats bynamewill displaybynamein theCONTAINERcolmun anddocker stats byidwill display the id in theCONTAINERcolumn) but adds two new format directive.$ docker stats 7c3 CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS 7c3 15.02% 666.5 MiB / 15.56 GiB 4.18% 22.46 MB / 3.56 MB 405.5 MB / 162.1 MB 71 $ docker stats --format="table {{.Names}}\t{{.ID}}\t{{.Container}}" 7c3 NAME CONTAINER ID CONTAINER elastic_agnesi 7c32fcc1c619123926f2c3cbc2356375b1887196b6b0cf3ed682973916bbb74e 7c3/cc @thaJeztah @dnephin
🐸
Signed-off-by: Vincent Demeester [email protected]