RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1093108 - Docker CLI ps command mangles data and represents with inconsistent column widths
Summary: Docker CLI ps command mangles data and represents with inconsistent column wi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Matthew Heon
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1109938
TreeView+ depends on / blocked
 
Reported: 2014-04-30 15:51 UTC by Chris Evich
Modified: 2019-03-06 00:44 UTC (History)
3 users (show)

Fixed In Version: docker-1.0
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-18 20:45:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1266 0 normal SHIPPED_LIVE docker bug fix and enhancement update 2014-09-19 00:45:12 UTC

Description Chris Evich 2014-04-30 15:51:23 UTC
Description of problem:
Docker CLI improperly parses, mangles then mis-represents commands in table

Version-Release number of selected component (if applicable):
0.9.1

How reproducible:
Easy

Steps to Reproduce:
1. # docker run fedora bash -c "echo 'this is a really really really really super big really really really really long command' > /tmp/foobar"
2. # docker ps --all --no-trunc
3. # docker run fedora bash -c "echo -e 'line  one\nline\ttwo\n\n\t\t\tline three'"
4. # docker ps --all --no-trunc
5. # FOO=`echo -e 'line  one\nline\ttwo\n\n\t\t\tline three'` docker run fedora bash -c "echo \'${FOO}\'"
6. # docker ps --all --no-trunc

Actual results:
[root@docker ~]# 
[root@docker ~]# docker run fedora bash -c "echo 'this  is  a  really  really  really  really  super  big  really  really  really  really  long  command'"
this  is  a  really  really  really  really  super  big  really  really  really  really  long  command
[root@docker ~]# docker ps --all --no-trunc
CONTAINER ID                                                       IMAGE               COMMAND                                                                                                                   CREATED             STATUS                     PORTS               NAMES
3352ec67936554d4dbddd747b1d13f6cf1743cc90533caf152711d3214a04e7b   fedora:20           bash -c 'echo 'this  is  a  really  really  really  really  super  big  really  really  really  really  long  command''   8 seconds ago       Exited (0) 5 seconds ago                       angry_torvalds      
[root@docker ~]# docker run fedora bash -c "echo -e 'line  one\nline\ttwo\n\n\t\t\tline three'"
line  one
line	two

			line three
[root@docker ~]# docker ps --all --no-trunc
CONTAINER ID                                                       IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
9197d0cec4eb92af38618289216a4c7fb3d055904fea78352b640c523c88363d   fedora:20           bash -c 'echo -e 'line  one
line                                                               two

                                                                                                                                                                                                                 line three''         17 seconds ago              Exited (0) 15 seconds ago                       drunk_heisenberg    
3352ec67936554d4dbddd747b1d13f6cf1743cc90533caf152711d3214a04e7b   fedora:20           bash -c 'echo 'this  is  a  really  really  really  really  super  big  really  really  really  really  long  command''   About a minute ago   Exited (0) 57 seconds ago                               angry_torvalds      
[root@docker ~]# # FOO=`echo -e 'line  one\nline\ttwo\n\n\t\t\tline three'` docker run fedora bash -c "echo \'${FOO}\'"
[root@docker ~]# FOO=`echo -e 'line  one\nline\ttwo\n\n\t\t\tline three'` docker run fedora bash -c "echo \'${FOO}\'"
'line one
bash: line 1: line: command not found
bash: line 3: line: command not found
[root@docker ~]# docker ps --all --no-trunc
CONTAINER ID                                                       IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
c0449d286d61e252707f6a1afbc329b9b9cd92cb1daf77c85154904b119b6e87   fedora:20           "bash -c 'echo \'line  one
line                                                               two

                                                                                                           line three\''"      15 seconds ago      Exited (127) 13 seconds ago                       clever_tesla        
9197d0cec4eb92af38618289216a4c7fb3d055904fea78352b640c523c88363d   fedora:20           bash -c 'echo -e 'line  one
line                                                               two

                                                                                                                                                                                                                 line three''         About a minute ago              Exited (0) About a minute ago                       drunk_heisenberg    
3352ec67936554d4dbddd747b1d13f6cf1743cc90533caf152711d3214a04e7b   fedora:20           bash -c 'echo 'this  is  a  really  really  really  really  super  big  really  really  really  really  long  command''   About a minute ago   Exited (0) About a minute ago                                   angry_torvalds      
[root@docker ~]# 


Expected results:

2. Column widths are set properly for this command, however quotes have been altered, i.e. " was replaced by '

4a. "COMMAND" Column width shrunk to 20-characters, no longer matches width for data from either container.
4b. In table data for #3 container, "COMMAND" column shows docker is parsing command and translating escape codes instead of passing them through literally (i.e. "\n" and "\t" are just strings, not literal newlines and tabs.
 
6a. "COMMAND" Column width shrunk to 20-characters, no longer matches width for data from any container.
6b. Similar to #4b, except literal newlines are NOT escaped, and output in newline-separated table-format.  i.e. row-delimiter for table not escaped in row data.

Additional info:

Setting to medium largely b/c #3, docker should not be interpreting any commands argument data, it should be passed through literally, as written.  Another example:

[root@docker ~]# docker run fedora bash -c "echo -e 'hidden data\b\b\b\b\b\b\b\b\b\b\b'"
hidden data
[root@docker ~]# docker ps --all --no-trunc
CONTAINER ID...
584e56f846c4be84bb3ac15cf5d25a821da593a7a0127959d3f3b38764febc4e   fedora:20           bash -c 'echo -e '''   ...

Comment 2 Matthew Heon 2014-06-20 15:56:56 UTC
Docker upstream seems to have fixed the alignment issues (column width and related issues), but newlines and other nonprintable and control characters are still not escaped. I'm working on a patch now.

Comment 3 Matthew Heon 2014-06-20 16:39:48 UTC
Pull request open with upstream: https://github.com/dotcloud/docker/pull/6573

It's unlikely this will make it into RHEL7's docker-1.0 build, but the subsequent release should include a fix.

Comment 4 Chris Evich 2014-06-20 20:51:35 UTC
Excellent, even just the column widths fix will help a lot.  Bonous points for escaping nonprintables :)

Comment 6 Matthew Heon 2014-06-25 14:17:03 UTC
Patch is now in RHEL7 docker-1.0 builds. This should definitely be a fix for the nonprintable/control characters issue.

I haven't been able to reproduce the column widths issue, so I'm assuming it was fixed upstream for 1.0. This should be tested further, though.

Comment 7 Chris Evich 2014-06-25 17:27:15 UTC
Great.  Yeah the column-width issue is a PITA to verify, I wound up literally counting columns by hand.  Though we have a test now that's very sensitive to header vs data column widths.  It should altert us of any problems, given whitespace-filled docker commands.  Thanks for the update.

Comment 8 Chris Evich 2014-07-18 19:12:52 UTC
All issues confirmed fixed in
docker-1.0.0-10.el7.x86_64
Client version: 1.0.0
Client API version: 1.12
Go version (client): go1.2.2
Git commit (client): 20fdb42/1.0.0
Server version: 1.0.0
Server API version: 1.12
Go version (server): go1.2.2
Git commit (server): 20fdb42/1.0.0

I ran the above steps to re-create, piped the output into ``hexdump -C | less`` and subtracted the end/startoffsets.  The COMMAND column header showed max of ~123 characters (including padding to next column).  All commands had all special characters properly escaped, and entire line was also quoted (nice touch).  Verified in all cases, the COMMAND column data was always padded out to the same ~123 characters (including pading to next column).  I also verified there were no unexpected (hidden) characters in the output, just regular ascii characters and newlines (linefeeds).   Yay!

Comment 10 errata-xmlrpc 2014-09-18 20:45:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1266.html


Note You need to log in before you can comment on or make changes to this bug.