Bug 1328242

Summary: docker events: 1.10 format is not reliably machine-readable
Product: Red Hat Enterprise Linux 7 Reporter: Ed Santiago <santiago>
Component: docker-latestAssignee: Antonio Murdaca <amurdaca>
Status: CLOSED EOL QA Contact: atomic-bugs <atomic-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dwalsh, jhonce, lsm5, lsu
Target Milestone: rcKeywords: Extras
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-04-10 12:57:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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...