Skip to content
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

Request: docker stats without any container should display all running containers #10772

Closed
phemmer opened this issue Feb 13, 2015 · 39 comments
Closed
Labels
exp/beginner kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/claimed

Comments

@phemmer
Copy link
Contributor

phemmer commented Feb 13, 2015

Similar to the behavior of the top utility, if no container is passed, it should show all containers. Since stopped containers are likely of no interest, I think it would be best to just show running containers.

@pskerrett
Copy link

It would be great, or at least allow a 'docker stats *'

Clunky workaround for now (I save it to my bash profile as alias docker-all-stats):

docker stats $(docker ps|grep -v "NAMES"|awk '{ print $NF }'|tr "\n" " ")

@phemmer
Copy link
Contributor Author

phemmer commented Feb 14, 2015

I don't like docker stats * because 1) it requires you to quote the * or the shell will expand it, and 2) it implies that the command does globbing, when it doesn't.

@jessfraz
Copy link
Contributor

Yes I was about to say the same thing about shell and *

On Friday, February 13, 2015, Patrick Hemmer notifications@github.com
wrote:

I don't like docker stats * because 1) it requires you to quote the * or
the shell will expand it, and 2) it implies that the command does globbing,
when it doesn't.


Reply to this email directly or view it on GitHub
#10772 (comment).

@phemmer
Copy link
Contributor Author

phemmer commented Feb 14, 2015

Oh, and there's a much simpler version of that command as well:

docker ps -q | xargs docker stats

@pskerrett
Copy link

True.. I guess 'docker stats -a' (or no flags at all) would be more appropriate.

@pskerrett
Copy link

That doesn't work exactly the way I'd like it. -q prints the container ID, but not the friendly name.

@phemmer
Copy link
Contributor Author

phemmer commented Feb 14, 2015

Have you tried it?
To be accurate, docker stats expects the containers to be listed as arguments, not one line, or space delimited. This is what xargs does. docker stats also works with both IDs and names.

@pskerrett
Copy link

You are right about the arguments, but I originally came up with that so its possible to print out all containers using their names, instead of by ID. I have 12 or more containers on each host so trying to cross reference containerID with friendly name is a pain.

@jessfraz jessfraz added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. white-belt labels Mar 2, 2015
@spf13 spf13 added exp/beginner kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. and removed kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. white-belt labels Mar 21, 2015
@mnuessler
Copy link

#dibs

@jmreicha
Copy link

+1

@sirupsen
Copy link
Contributor

Agree 👍 The current behaviour always catches me by surprise.

@SamSaffron
Copy link

+1

@nhsiehgit
Copy link
Contributor

@jfrazelle

closed by #11763 ?

@SamSaffron
Copy link

no, that was just a dupe

@avignat
Copy link

avignat commented Mar 29, 2015

+1

@runcom
Copy link
Member

runcom commented Mar 29, 2015

+1 @mnuessler any update on this?

@mnuessler
Copy link

@runcom currently working on it..

@mnuessler
Copy link

Just want to give a short update on this: I got something working, but still need to provide a test. And I have two questions:

  • Should docker stats display the ID or the name of the running containers? I assume the name would be more useful?
  • If a container stops while stats is running, should the entry be removed from the displayed list?

@phemmer
Copy link
Contributor Author

phemmer commented Mar 31, 2015

My own personal opinions:

I see value in both name and ID. Personally, I never use names. I use IDs everywhere. But I know others are the opposite. The only options I see to satisfy that would be to either show both, or a flag to control it.

Yes, container should be removed from the list.
The output you get while it is running should be the same output you get if you were to start it up again.

@avignat
Copy link

avignat commented Apr 1, 2015

I agree with @phemmer for both propositions. I never use names too.

@joost
Copy link

joost commented Apr 1, 2015

+1 (name and id / remove from list when stopped)

@thaJeztah
Copy link
Member

@mnuessler do you have a status update?

If you're unsure about your implementation, it's no problem to create a PR with some "unpolished" things in it, because you will be able to discuss those issues during the design-review. Sometimes it helps to just create the PR so that the maintainers/reviewers have something to discuss.

And possibly, you'll learn some things or get inspiration in the process!

Just let us know, (also if you are unable to work on it) thanks in advance!

@DavidBadura
Copy link

+1

1 similar comment
@terbooter
Copy link

+1

@runcom
Copy link
Member

runcom commented May 13, 2015

@mnuessler are you still working on this? If you need any help feel free to ping me here or on IRC

@dalanmiller
Copy link

👍 to this, no other way currently to continuously display all running containers.

@SamSaffron
Copy link

please please please...

docker stats `docker ps | awk '{print $NF}' | grep -v NAMES`

is gonna go in our bash rc file :)

@thaJeztah
Copy link
Member

ping @mnuessler if you're still working on this.

@runcom perhaps you are interested in picking this up otherwise?

@runcom
Copy link
Member

runcom commented Jun 28, 2015

@thaJeztah I'm still working on this (though slowly for lack of time :()

@hbbio
Copy link

hbbio commented Aug 18, 2015

+1 for the feature (with docker stats, no *)

@shishir-a412ed
Copy link
Contributor

@runcom any updates on this one ?

@iangkent
Copy link

+1 for docker stats that show container names in output instead of need to remember docker stats docker ps | awk '{print $NF}' | grep -v NAMES

@thaJeztah
Copy link
Member

PR for this is opened here; #16742

@tiurikov
Copy link

docker stats $(docker ps -aq) works ok for me.

@SamSaffron
Copy link

ok is a funny word ... you must love guids :)

On Wed, Oct 14, 2015 at 11:52 PM, Stanislav Tyurikov <
notifications@github.com> wrote:

docker stats $(docker ps -aq) works ok for me.


Reply to this email directly or view it on GitHub
#10772 (comment).

@cboettig
Copy link

Well said @SamSaffron . me, i'd like to see container names when they have them.

@tiurikov
Copy link

@SamSaffron you caught me. :)
docker stats $(docker inspect -f "{{ .Name }}" $(docker ps -aq))
And I totally agree, it would be nice to have just "docker stats".

@sergej-brazdeikis
Copy link

You can also use simpler version:

docker stats `docker ps -q`

@thaJeztah
Copy link
Member

@sjevs this feature was implemented in #16742 over two years ago, and is part of Docker 1.10 and up:

docker run -d --rm nginx:alpine
docker run -d --rm nginx:alpine

docker stats

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
7f58203c7640        fervent_hopper      0.00%               1.836MiB / 1.952GiB   0.09%               578B / 0B           0B / 0B             2
fba8e312a88f        dreamy_pasteur      0.00%               1.922MiB / 1.952GiB   0.10%               758B / 0B           4.66MB / 0B         2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/beginner kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/claimed
Projects
None yet
Development

Successfully merging a pull request may close this issue.