-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Default "docker ps" output is too wide #7477
Comments
So much love and many +1s. I use 80x24 terminals (much to the chagrin of |
I have to say this often gets me as well. Any ideas for a solution? Having a smaller version on narrower terminals sounds nice. |
Well, ID doesn't really need to be there. |
How about this:
Explanation:
|
@bfirsh 👍 with these notes;
|
What's wrong with piping to a pager? docker ps | less -S |
@benjamin-thomas or |
Nice trick @benjamin-thomas , I will definitely use that in the future. One consideration is that does leave off information I care about, most importantly, container names. Whereas in my usecase I don't usually care as much about e.g. |
IMO the use case may vary among users, for me, I'm not really sure if this should become a large re-implementation of ps output, or to start with making it a bit cleaner by default and building upon that, making it more configurable by adding options to specify columns to show, sort order and filtering. |
@nathanleclaire, just use your arrow keys once you're inside @grahamc why not, personally I prefer tools not to do those things automatically. One could always define a shell alias for this IMO if that's needed. @thaJeztah specifying the column names with switches makes sense to me, like the system ps command |
@benjamin-thomas Oh, I hadn't even realized that. Nice! I like this solution a lot. |
@benjamin-thomas |
Related to the width of Then if B also links to, say, D, E gets even MORE names: B/D/E and A/B/D/E. One run of the system I'm working on starts seventeen containers -- which, all together, owing to 31 dependency relationships, have three hundred and eighty-seven names. No matter how wide I make my terminal windows, the output of |
@MrAccident 👍 |
Salut, it was bothering me as well and I just added a '--short' option to docker. keeping the complete port-column.
Since I am a newbe to go, I guess my code could be... optimized... EDIT: Maybe one could fetch the size of the terminal and kick out columns to shorten the lines... EDIT2: I shorten the NAMES and added a count(CHILDREN), even though it is a little bit misleading, because it counts fd3->fd2->fd1 as well.
EDIT3: Now I extract the correct name
|
I feel that the ports definition and the verbosity of the times are a big part of the width of the
|
What about allowing to provide a template for example by setting an environment variable |
I wrote this bash/zsh function in my
|
Workaround hack. Modify which $cols[x] you want to keep as desired.
|
Wouldn't it be easier to have something like:
and everybody could just alias |
`dps`: Show an abridged list of *running* Docker containers `dpsa`: Show an abridged list of *all* Docker containers Assumes terminal column width of 120. Credit goes to: moby/moby#7477 (comment)
Thanks, @caiguanhao. Clever interim solution. Added it as a Tackle plugin for the fish shell. |
Guys, just made a small improvement on @caiguanhao's code to be able to choose which columns to show. When you have a container that exposes many ports (like the Consul service, which exposes 5 or 6 ports and can make even a 300-characters-wide screen overflow), it's nice to have a command to show every column except those ports, and then another one that shows only the name of the containers and its ports (I added these options as new commands by default): https://github.com/jpmelos/dotfiles/commit/457a9c68f87eb5bd455aa22bdadab81c2651c2ea |
One simple change that would help a little is to reduce the spacing between the CONTAINER ID and IMAGE columns. The other columns are all separated by 3 spaces, but these two are separated by 8. |
|
put this in your ~/.docker/config.json And modify to your liking. For me the problem was always long image name (since it contained my personal repository name for my custom images) |
everyone who is looking for a better docker ps should check this out: |
Thanks. This was all that I needed: giving IMAGE STATUS NAMES EDIT it it better to create a bash alias with something like this:
Notice the "table" format |
That's awesome, thnx |
@nagracks if you want that format as default, I'd recommend using the |
If I modify my
How can I then use the |
Using |
I would really appreciate if there was a less-verbose version of the output available by default, without having to remember what the table formatting syntax is or what the variable names are in the formatting context. Even if the default would be kept as it is, a flag for a pre-formatted less verbose version would be useful. As to what information could be reduced from a less verbose version, here's my two cents:
In my use case I usually just want to look up the name of the container I'll be running some other commands against (e.g. on a remote server node), and having the output be wrapped across multiple lines makes it difficult to find out the exact name of the container I'm interested in. I'm somewhat disappointed the "approved" solution here is "just configure an alias with --format parameter", as if you would always be running these commands in environments where you have your alias defined, or remember the formatting syntax and context variables |
I still run into this issue daily, FWIW. My current output of
The average user shouldn't be expected to alias their I'm tempted to open a pull request as a strawman. 😏 |
I cannot for the life of me fathom that this issue is 7 years old now and nothing has been done about it. |
Various changes have been made; see the discussion above; Use the $ docker ps --format "table {{ .ID }}\t{{.Names}}\t{{.Status}}"
CONTAINER ID NAMES STATUS
c1ddaacec4b1 foo.2.otc3vwejh16cvgtttm0uzmvmv Up 2 days
073997fd8e95 foo.1.p9vr6bb44vsnmzbphbkptam9m Up 2 days
c4bd87d6b496 foo.5.5lzhyu8ncnncbxufsrtsnmwd0 Up 2 days
8b534ba4b653 foo.3.t4en4k5gu16pbnu5pjz72n3im Up 2 days
924bbaef36ba foo.4.vxx38l4ma1byk8j9kd4xvcqbe Up 2 days Or specify your custom format in the {
"psFormat": "table {{ .ID }}\\t{{ .Names }}\t{{ .Status }}"
} Docker 20.10 in addition reduces the space between columns / minimal column width (docker/cli#2699). Default output now looks like (~122 characters wide); $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c1ddaacec4b1 nginx:alpine "/docker-entrypoint.…" 2 days ago Up 2 days 80/tcp foo.2.otc3vwejh16cvgtttm0uzmvmv
073997fd8e95 nginx:alpine "/docker-entrypoint.…" 2 days ago Up 2 days 80/tcp foo.1.p9vr6bb44vsnmzbphbkptam9m
c4bd87d6b496 nginx:alpine "/docker-entrypoint.…" 2 days ago Up 2 days 80/tcp foo.5.5lzhyu8ncnncbxufsrtsnmwd0
8b534ba4b653 nginx:alpine "/docker-entrypoint.…" 2 days ago Up 2 days 80/tcp foo.3.t4en4k5gu16pbnu5pjz72n3im
924bbaef36ba nginx:alpine "/docker-entrypoint.…" 2 days ago Up 2 days 80/tcp foo.4.vxx38l4ma1byk8j9kd4xvcqbe There never will be a one-size-fits-all selection of columns as different users / use-cases need different information, which is why it's made configurable. |
Awesome, thanks. Made an alias for this and added it to my |
Would it be possible to have an option to wrap the table? Kind of like this (same output as in bfirsh's last comment):
This is how they display data-frames that are too wide to fit within the width of the terminal in Python's Pandas library. I tried to achieve something like this using |
This would be useful for me as well, any resolution would be incredibly welcome. |
^This. If we could have the option tell it to add a CR after each var in the array, vs just having them spew out on one line, that'd be amazing. |
Actually a good idea, I took the liberty and implemented it into an kinda-alternative docker-ps tool. (I created a bash function to drop-in replace |
Nice ! I like the way it displays ports & IP installed ;-) |
Bash script to output docker ps in narrow mode with ports wrapping |
Neat: the utter unusability of this has almost made it to a decade! |
indeed.. not only did it make it almost to a decade, previous solutions got lost along the way too! here mine in plain awk from 8 years ago with wrapping ports.. still using it to this day: |
The default output of docker ps on one of my systems is over 200 columns wide. Very painful that the devs seem to think this is acceptable behavior. |
When I don't need all the data I use a bash function that just cut's off the output at the current terminal width which is fine most of the times for a quick check. The alias could of course also contain any custom format if you want to shorten it before cutting it off.
|
Less effective than the following (taken from previous comments)
so as a function
|
You can configure your preferred format in |
What I want is for the command to use the decades-old methods to gather information about the terminal it’s running in and do the right thing like every other unix utility—JasonOn Sep 4, 2023, at 6:59 AM, Sebastiaan van Stijn ***@***.***> wrote:
You can configure your preferred format in ~/.docker/config.json if you don't want to use an alias; #7477 (comment)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
I appreciate this long running discussion, this topic also bumps me from the beginning of using Docker (like many others it seems). The CONTAINER ID NAMES IMAGE STATUS
546899e78e1e services-redis-1 redis:latest Exited (0) 2 months ago
3eb2727e93b8 hardcore_hodgkin vsc-project-xyz-5581627750211c75baca9d4a3e298e24d5bccfbbecc4ea967f7eabdb7a93de19-features-uid Exited (255) 2 weeks ago Is there an inbuilt solution for that (without piping to e.g. awk, less)? I would like to see an generall option like |
so no progress for 10y? would some really important people indirectly lose money if this gets implemented? otherwise I can't explain it |
there exist workarounds like mine, so nobody is really too bothered by it. |
Output from
docker ps
is very hard to read on 80 character wide terminals./bin/ps
does a pretty good job of wrapping output on narrow terminals (e.g. putting important information first, command last and truncating it). I wonder if we can do better.The text was updated successfully, but these errors were encountered: