New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Docker stats to show names instead of IDs #20973

Closed
omercnet opened this Issue Mar 5, 2016 · 30 comments

Comments

Projects
None yet
@omercnet

omercnet commented Mar 5, 2016

I've never found docker stats useful by itself and always amended it with docker stats $(docker ps --format={{.Names}})

What do you think about showing names by default?

@HackToday

This comment has been minimized.

Show comment
Hide comment
@HackToday

HackToday Mar 5, 2016

Contributor

@omercnet what do you use it for ? Doesdocker stats $(docker ps --format={{.Names}}) fulfill your purpose ?
I am thinking what's the strong reason to add name in docker stats?

Contributor

HackToday commented Mar 5, 2016

@omercnet what do you use it for ? Doesdocker stats $(docker ps --format={{.Names}}) fulfill your purpose ?
I am thinking what's the strong reason to add name in docker stats?

@omercnet

This comment has been minimized.

Show comment
Hide comment
@omercnet

omercnet Mar 5, 2016

I use it for general monitoring of stats while running/testing, I can't tell which container is which just based on IDs, that's what names are for

I originally was looking maybe adding --names or something like that to stats

Aside from when running a single container (in which case it doesn't matter), is there any use case for showing just IDs ?

omercnet commented Mar 5, 2016

I use it for general monitoring of stats while running/testing, I can't tell which container is which just based on IDs, that's what names are for

I originally was looking maybe adding --names or something like that to stats

Aside from when running a single container (in which case it doesn't matter), is there any use case for showing just IDs ?

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Mar 5, 2016

Member

IIRC, currently it shows what you "requested", i.e. docker stats 39b69226f9d7 will show the id, whereas docker stats foobar shows the name of the container. Given that docker ps shows both container name and id (in separate columns), I can see it being consistent to show both. Ideally (but possibly a separate feature request), add a --format flag, so that users can define which columns to include.

I'm +1 for improving this, but open to additional suggestions / thoughts

Member

thaJeztah commented Mar 5, 2016

IIRC, currently it shows what you "requested", i.e. docker stats 39b69226f9d7 will show the id, whereas docker stats foobar shows the name of the container. Given that docker ps shows both container name and id (in separate columns), I can see it being consistent to show both. Ideally (but possibly a separate feature request), add a --format flag, so that users can define which columns to include.

I'm +1 for improving this, but open to additional suggestions / thoughts

@omercnet

This comment has been minimized.

Show comment
Hide comment
@omercnet

omercnet Mar 5, 2016

@thaJeztah you're right, that's why the I added $(docker ps --format={{.Names}}) so I would pass the names to docker stats

so perhaps only in cases when someone runs docker stats without any parameters it would display both, and if the user specifies an ID(s) or Name(s) it would display just those ? Just like docker ps adds NAMES at the end

omercnet commented Mar 5, 2016

@thaJeztah you're right, that's why the I added $(docker ps --format={{.Names}}) so I would pass the names to docker stats

so perhaps only in cases when someone runs docker stats without any parameters it would display both, and if the user specifies an ID(s) or Name(s) it would display just those ? Just like docker ps adds NAMES at the end

@gigidwan

This comment has been minimized.

Show comment
Hide comment
@gigidwan

gigidwan Mar 10, 2016

I would like to work on this as my first assignment.

As far as I understand, showing both container ID and name for both cases where we pass an argument to command or without one, would be consistent, in that case users will also be having option to include whatever they want. Please let me know, if this is the scope and if I can go ahead and work on it.

Thanks.

gigidwan commented Mar 10, 2016

I would like to work on this as my first assignment.

As far as I understand, showing both container ID and name for both cases where we pass an argument to command or without one, would be consistent, in that case users will also be having option to include whatever they want. Please let me know, if this is the scope and if I can go ahead and work on it.

Thanks.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Mar 11, 2016

Member

@gigidwan sounds good to me (other maintainers may have different thoughts, but can comment on the PR once it's up). Thanks in advance for working on it!

Member

thaJeztah commented Mar 11, 2016

@gigidwan sounds good to me (other maintainers may have different thoughts, but can comment on the PR once it's up). Thanks in advance for working on it!

@gigidwan

This comment has been minimized.

Show comment
Hide comment
@gigidwan

gigidwan Mar 12, 2016

@thaJeztah Thanks, so I started working on a PR for this.. just to clarify my understanding I would like to share the output here..

# docker stats
CONTAINER_ID        NAMES               CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O           PIDS
ab4c4a246389        elated_mcnulty      0.00%               4.87 MB / 2.099 GB    0.23%               1.366 kB / 1.108 kB   4.37 MB / 0 B       0
a2ccc83eb793        69b4eb4a3927        0.00%               847.9 kB / 2.099 GB   0.04%               2.056 kB / 1.108 kB   770 kB / 0 B        0

And when an argument is passed

# docker stats elated_mcnulty
CONTAINER_ID                                                       NAMES               CPU %               MEM USAGE / LIMIT    MEM %               NET I/O               BLOCK I/O           PIDS
ab4c4a246389444d475f2ed3c49b391601a6f185e7342931658431566200825a   elated_mcnulty     0.00%               4.87 MB / 2.099 GB   0.23%               1.366 kB / 1.108 kB   4.37 MB / 0B       0

so, my confusion here is regarding the ID length, I believe it should be same in both the cases, but what length it should be.. or are we planning to show the length which user specifies when he is passing container ID as an argument..

Can you please clear my doubt here, so I would go ahead accordingly.

gigidwan commented Mar 12, 2016

@thaJeztah Thanks, so I started working on a PR for this.. just to clarify my understanding I would like to share the output here..

# docker stats
CONTAINER_ID        NAMES               CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O           PIDS
ab4c4a246389        elated_mcnulty      0.00%               4.87 MB / 2.099 GB    0.23%               1.366 kB / 1.108 kB   4.37 MB / 0 B       0
a2ccc83eb793        69b4eb4a3927        0.00%               847.9 kB / 2.099 GB   0.04%               2.056 kB / 1.108 kB   770 kB / 0 B        0

And when an argument is passed

# docker stats elated_mcnulty
CONTAINER_ID                                                       NAMES               CPU %               MEM USAGE / LIMIT    MEM %               NET I/O               BLOCK I/O           PIDS
ab4c4a246389444d475f2ed3c49b391601a6f185e7342931658431566200825a   elated_mcnulty     0.00%               4.87 MB / 2.099 GB   0.23%               1.366 kB / 1.108 kB   4.37 MB / 0B       0

so, my confusion here is regarding the ID length, I believe it should be same in both the cases, but what length it should be.. or are we planning to show the length which user specifies when he is passing container ID as an argument..

Can you please clear my doubt here, so I would go ahead accordingly.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Mar 12, 2016

Member

@gigidwan I think we should show the truncated ID by default (I think we use 12 characters everywhere, see https://github.com/docker/docker/blob/160abfbeeaa20314d5d971061d3bad7aaf87e66c/integration-cli/docker_cli_stats_test.go#L61, and https://github.com/docker/docker/blob/fff1511c56e35cf5230d05af2282d31d23a31dc0/docs/admin/logging/log_tags.md#L27)

We could think of using a --no-trunc flag, similar to docker ps --no-trunc, or leave that to the PR where we add --format (hence the second link above)

Member

thaJeztah commented Mar 12, 2016

@gigidwan I think we should show the truncated ID by default (I think we use 12 characters everywhere, see https://github.com/docker/docker/blob/160abfbeeaa20314d5d971061d3bad7aaf87e66c/integration-cli/docker_cli_stats_test.go#L61, and https://github.com/docker/docker/blob/fff1511c56e35cf5230d05af2282d31d23a31dc0/docs/admin/logging/log_tags.md#L27)

We could think of using a --no-trunc flag, similar to docker ps --no-trunc, or leave that to the PR where we add --format (hence the second link above)

@gigidwan

This comment has been minimized.

Show comment
Hide comment
@gigidwan

gigidwan Mar 12, 2016

@thaJeztah sure, sounds good to me.
Thanks :)

gigidwan commented Mar 12, 2016

@thaJeztah sure, sounds good to me.
Thanks :)

@SamSaffron

This comment has been minimized.

Show comment
Hide comment
@SamSaffron

SamSaffron Jun 7, 2016

@gigidwan any news on this?

SamSaffron commented Jun 7, 2016

@gigidwan any news on this?

@boaz1337

This comment has been minimized.

Show comment
Hide comment
@boaz1337

boaz1337 Jul 13, 2016

Member

@thaJeztah can I "dibs"?

If I understand correctly, we are going to implement the format flag in stats, right?

#dibs

Member

boaz1337 commented Jul 13, 2016

@thaJeztah can I "dibs"?

If I understand correctly, we are going to implement the format flag in stats, right?

#dibs

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jul 13, 2016

Member

@ripcurld00d yes, that's the idea; that way we can keep the regular output as-is, but allow people to pick additional/other columns if desired

Member

thaJeztah commented Jul 13, 2016

@ripcurld00d yes, that's the idea; that way we can keep the regular output as-is, but allow people to pick additional/other columns if desired

@fane89

This comment has been minimized.

Show comment
Hide comment
@fane89

fane89 commented Jul 14, 2016

👍

@SamSaffron

This comment has been minimized.

Show comment
Hide comment
@SamSaffron

SamSaffron Jul 14, 2016

My two cents, requiring contortion to get a 'docker stats' to return sane
names as opposed to user hostile guids defeats the spirit of this request

On Thursday, 14 July 2016, Thomas notifications@github.com wrote:

👍


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#20973 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAUXcVZN_gCTAef7a9EHV-FS3XiFPhyks5qVeAQgaJpZM4Hp-TT
.

SamSaffron commented Jul 14, 2016

My two cents, requiring contortion to get a 'docker stats' to return sane
names as opposed to user hostile guids defeats the spirit of this request

On Thursday, 14 July 2016, Thomas notifications@github.com wrote:

👍


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#20973 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAUXcVZN_gCTAef7a9EHV-FS3XiFPhyks5qVeAQgaJpZM4Hp-TT
.

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jul 14, 2016

Contributor

Agree, I see no reason to return ID's, and ID's and names are interchangeable as far as the API is concerned so not really anything I can see as a back-compat issue.

Contributor

cpuguy83 commented Jul 14, 2016

Agree, I see no reason to return ID's, and ID's and names are interchangeable as far as the API is concerned so not really anything I can see as a back-compat issue.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jul 14, 2016

Member

I'm okay personally with changing the default, but there were some concerns raised on an earlier PR: #21185 (comment)

Having a --format flag would be consistent with other commands, and unblock this PR: #21178

Member

thaJeztah commented Jul 14, 2016

I'm okay personally with changing the default, but there were some concerns raised on an earlier PR: #21185 (comment)

Having a --format flag would be consistent with other commands, and unblock this PR: #21178

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jul 14, 2016

Contributor

We can still use ID's in the backend (for watching events or whatever), but display names.

Contributor

cpuguy83 commented Jul 14, 2016

We can still use ID's in the backend (for watching events or whatever), but display names.

@boaz1337

This comment has been minimized.

Show comment
Hide comment
@boaz1337

boaz1337 Jul 18, 2016

Member

#dibs

Member

boaz1337 commented Jul 18, 2016

#dibs

@jeanpralo

This comment has been minimized.

Show comment
Hide comment
@jeanpralo

jeanpralo commented Aug 4, 2016

👍

@twang2218

This comment has been minimized.

Show comment
Hide comment
@twang2218

twang2218 Sep 1, 2016

Every time I use docker stats, I have to use docker stats $(docker ps --format={{.Names}}), otherwise, I have totally no idea which container is which. And I don't think docker stats $(docker ps --format={{.Names}}) is the solution, because it's static container list. I have to stop and rerun this command if I remove a container, or run a new container.

It make more sense if there is a name column in the docker stats by default.

twang2218 commented Sep 1, 2016

Every time I use docker stats, I have to use docker stats $(docker ps --format={{.Names}}), otherwise, I have totally no idea which container is which. And I don't think docker stats $(docker ps --format={{.Names}}) is the solution, because it's static container list. I have to stop and rerun this command if I remove a container, or run a new container.

It make more sense if there is a name column in the docker stats by default.

@dunk

This comment has been minimized.

Show comment
Hide comment
@dunk

dunk Sep 2, 2016

Just came across this myself. Very much agree with @twang2218. Would love this feature by default!

dunk commented Sep 2, 2016

Just came across this myself. Very much agree with @twang2218. Would love this feature by default!

@rbravo-avantrip

This comment has been minimized.

Show comment
Hide comment
@rbravo-avantrip

rbravo-avantrip Sep 6, 2016

Meanwhile this alias can cover what @twang2218 said:

alias ds='while true; do TEXT=$(docker stats --no-stream $(docker ps --format={{.Names}})); sleep 0.1; clear; echo "$TEXT"; done'

rbravo-avantrip commented Sep 6, 2016

Meanwhile this alias can cover what @twang2218 said:

alias ds='while true; do TEXT=$(docker stats --no-stream $(docker ps --format={{.Names}})); sleep 0.1; clear; echo "$TEXT"; done'
@boaz1337

This comment has been minimized.

Show comment
Hide comment
@boaz1337

boaz1337 Nov 16, 2016

Member

@thaJeztah
#27797 was merged, I think you can close it.

Member

boaz1337 commented Nov 16, 2016

@thaJeztah
#27797 was merged, I think you can close it.

@rmoriz

This comment has been minimized.

Show comment
Hide comment
@rmoriz

rmoriz Apr 15, 2017

Contributor

This is not solved. OP asked for a solution that works without having to specify the complete format manually IMHO.

The added --format option is even more inconvenient than running the ridiculous docker stats $(docker ps --format={{.Names}})

Contributor

rmoriz commented Apr 15, 2017

This is not solved. OP asked for a solution that works without having to specify the complete format manually IMHO.

The added --format option is even more inconvenient than running the ridiculous docker stats $(docker ps --format={{.Names}})

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Apr 15, 2017

Member

@rmoriz you can set your custom format in ~/.docker/config.json so that you don't have to type it when using docker stats. We may change the default at some point, but decided not to at this point

Member

thaJeztah commented Apr 15, 2017

@rmoriz you can set your custom format in ~/.docker/config.json so that you don't have to type it when using docker stats. We may change the default at some point, but decided not to at this point

@mjaggard

This comment has been minimized.

Show comment
Hide comment
@mjaggard

mjaggard May 17, 2017

I come here twice a day to copy and paste this stupid command docker stats $(docker ps --format={{.Names}})

mjaggard commented May 17, 2017

I come here twice a day to copy and paste this stupid command docker stats $(docker ps --format={{.Names}})

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah May 17, 2017

Member

@mjaggard open the file ~/.docker/config.json in an editor, and modify it to look like this (where "other-option-1" and "other-option-2" are existing configuration options you may have in that file);

{
  "other-option-1":"foo",
  "other-option-2":"bar",
  "statsFormat": "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDs}}"
}

After that, Names will be used by default. You can add/remove other columns by changing the template, valid options can be found here: https://docs.docker.com/engine/reference/commandline/stats/#formatting

Member

thaJeztah commented May 17, 2017

@mjaggard open the file ~/.docker/config.json in an editor, and modify it to look like this (where "other-option-1" and "other-option-2" are existing configuration options you may have in that file);

{
  "other-option-1":"foo",
  "other-option-2":"bar",
  "statsFormat": "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDs}}"
}

After that, Names will be used by default. You can add/remove other columns by changing the template, valid options can be found here: https://docs.docker.com/engine/reference/commandline/stats/#formatting

@stevenmyhre

This comment has been minimized.

Show comment
Hide comment
@stevenmyhre

stevenmyhre Aug 30, 2017

How often does one care about seeing the CPU of a container by ID? Do people just memorize their container IDs?

stevenmyhre commented Aug 30, 2017

How often does one care about seeing the CPU of a container by ID? Do people just memorize their container IDs?

@famousgarkin

This comment has been minimized.

Show comment
Hide comment
@famousgarkin

famousgarkin Sep 22, 2017

I'd expect both IDs and names from docker stats by default if only because docker ps already gives you both.

famousgarkin commented Sep 22, 2017

I'd expect both IDs and names from docker stats by default if only because docker ps already gives you both.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Sep 28, 2017

Member

Good new everyone: I decided to open a PR for changing the default format to show CONTAINER ID (truncated) and NAME by default, and add a --no-trunc flag to docker stats. The PR was just merged, so will be in an upcoming Docker release (17.10 or 17.11); docker/cli#565

Member

thaJeztah commented Sep 28, 2017

Good new everyone: I decided to open a PR for changing the default format to show CONTAINER ID (truncated) and NAME by default, and add a --no-trunc flag to docker stats. The PR was just merged, so will be in an upcoming Docker release (17.10 or 17.11); docker/cli#565

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment