Description
docker stats command takes up too much horizontal space by default. It wraps needlessly.
Steps to reproduce the issue:
Describe the results you received:
Output is
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PID
S
f6eb2e8ad9fd xxxxxxxxxxxx 1.64% 84.71MiB / 15.64GiB 0.53% 14.4kB / 0B 119MB / 262kB 128
3cd473910948 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0.15% 7.619GiB / 15.64GiB 48.72% 1.32MB / 27.1kB 1.13GB / 1.42GB 118
Describe the results you expected:
I would expect the output to not wrap on such a wide display.
Something like the following would be more appropriate.
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
f6eb2e8ad9fd xxxxxxxxxxxx 1.64% 84.71MiB / 15.64GiB 0.53% 14.4kB / 0B 119MB / 262kB 128
3cd473910948 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0.15% 7.619GiB / 15.64GiB 48.72% 1.32MB / 27.1kB 1.13GB / 1.42GB 118
Additional information you deem important (e.g. issue happens only occasionally):
This happens every time the command is run if the display is less than 172 characters wide.
Output of docker version:
Docker version 19.03.12, build 48a66213fe
Output of docker info:
Not required as this is a feature request.
Additional environment details (AWS, VirtualBox, physical, etc.):
Using Windows Terminal with byobu sshed into Ubuntu 16.
Hi @rpwjanzen , how are you? Do you need all columns from docker stats? All the fields in the default template of stats table are spaced with \t, and made a change in this structure could cause some harm to other users (I think). We could modify the \t to some \s to percentual fields because they are the smallest fields.
However, you can format your output using the flag --format, maybe this could be a solution to you.
What do you think?
@maximillianfx Thank you for your rapid feedback.
I do not need all the columns from docker status. I understand that changing this structure could break other application workflows, which is clearly undesirable. Given that the user can configure the output using the '--format' flag, I believe this FR can be resolved. I continue to remain slightly disappointed with the state of the software industry as I feel this feature as built violates the "sensible defaults" ideal.
Regardless, thank you for your time and I wish you best of luck during the pandemic.
While the template uses a \t, the output is written with a tab-writer that formats the output using spaces to align columns. I had a quick look at the code, and I see there's a minimum-width specified of 20 positions for columns, which would explain the large gap between some columns.
Perhaps it was done for a specific reason (I recall there have been some corner-cases in the past) but let me try a quick PR to see if changing works.
@thaJeztah the template is used only if we do not provide flags to the stats command or the tab-writter is always called?
The tabwriter is always called to render table views. The default table format also uses tabs (and those are converted to spaces when printing, which is done by the tabwriter); https://github.com/docker/cli/blob/0904fbfc77dbd4b6296c56e68be573b889d049e3/cli/command/container/formatter_stats.go#L14
Most helpful comment
@maximillianfx Thank you for your rapid feedback.
I do not need all the columns from
docker status. I understand that changing this structure could break other application workflows, which is clearly undesirable. Given that the user can configure the output using the '--format' flag, I believe this FR can be resolved. I continue to remain slightly disappointed with the state of the software industry as I feel this feature as built violates the "sensible defaults" ideal.Regardless, thank you for your time and I wish you best of luck during the pandemic.