Bug 1328242 - docker events: 1.10 format is not reliably machine-readable
Summary: docker events: 1.10 format is not reliably machine-readable
Keywords:
Status: CLOSED EOL
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker-latest
Version: 7.2
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Antonio Murdaca
QA Contact: atomic-bugs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-18 20:01 UTC by Ed Santiago
Modified: 2019-04-10 12:57 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-04-10 12:57:39 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Ed Santiago 2016-04-18 20:01:14 UTC
docker 1.10 brings significant changes to the format of the events command:

    - <timestamp> <sha> (from <source>) <operation>
    + <timestamp> <type> <operation> <identifier> (key1=val1, key2=val2)

The parenthesized key=value pairs are comma-separated but there's no protection for commas, making it challenging to parse something like:

      (Release=56, Vendor=Red Hat, Inc., Name=rhel7/rhel, ...)

There are many possible ways to address this. Some possibilities:

    * Backslash-escape commas within key or value: Vendor=Red Hat\, Inc.
    * Escape commas as HTML entities or using URL escaping: Vendor=Red Hat&#2C; Inc. or =Red Hat%2C Inc.
    * Double-quote values that contain space/comma/other: Vendor="Red Hat, Inc."

Note that commas aren't the only characters needing escape: also equal sign, and possibly close-paren. And, given any of the above mechanisms, its corresponding escape character itself (backslash, ampersand, percent, double-quote).

This is a can of worms, and there is not currently a compelling reason to parse this output... but there will be. Best to sort this out early and document it clearly.

Comment 3 Antonio Murdaca 2016-10-23 13:50:37 UTC
Reported upstream https://github.com/docker/docker/issues/27667, let's see how the conversation goes.

Comment 4 Antonio Murdaca 2016-10-24 10:35:11 UTC
There's a way to format the "docker events" to something like json for machine parsing (it uses Golang templates):

$ docker events --format '{{json .}}'

{"status":"create","id":"fc23ee06aa4bf27101795fc9d952fc4319861f5e3f0d1f66003d9ee699e22e38","from":"busybox","Type":"container","Action":"create","Actor":{"ID":"fc23ee06aa4bf27101795fc9d952fc4319861f5e3f0d1f66003d9ee699e22e38","Attributes":{"image":"busybox","name":"naughty_dijkstra","test":"a, really) not machine=readable)label,"}},"time":1477305133,"timeNano":1477305133564203266}
{"status":"attach","id":"fc23ee06aa4bf27101795fc9d952fc4319861f5e3f0d1f66003d9ee699e22e38","from":"busybox","Type":"container","Action":"attach","Actor":{"ID":"fc23ee06aa4bf27101795fc9d952fc4319861f5e3f0d1f66003d9ee699e22e38","Attributes":{"image":"busybox","name":"naughty_dijkstra","test":"a, really) not machine=readable)label,"}},"time":1477305133,"timeNano":1477305133570380122}

This will be in docker 1.13.x. (not sure how to close this bug)

Comment 5 Daniel Walsh 2016-10-24 13:18:37 UTC
Excellent. No work for us either

Comment 9 Lokesh Mandvekar 2019-04-10 12:57:39 UTC
docker-latest is EOL. Closing...


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