docker / docker/cli

[RFD] JSON output produced by --format should not prettify values

Open
#674 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/ux kind/enhancement
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

I noticed this a couple of times, but didn't open an issue yet; when using the --format option on commands, and requesting json output, the values included in the output should output the raw values, not the formatted output as is used in other formats.

For example:

$ docker ps --format '{{json .}}' | jq . 
{
  "Command": "\"nginx -g 'daemon of…\"",
  "CreatedAt": "2017-11-07 13:30:41 +0100 CET",
  "ID": "6f02a463250c",
  "Image": "nginx:alpine",
  "Labels": "com.docker.swarm.task=,com.docker.swarm.task.id=gwbj2pzql8r6ovcyw2s61piyy,com.docker.swarm.task.name=myservice.1.gwbj2pzql8r6ovcyw2s61piyy,maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>,com.docker.swarm.node.id=url9rx710g8azgnhpmpr9hqfl,com.docker.swarm.service.id=2plef0c7wdya64ball1an4u2j,com.docker.swarm.service.name=myservice",
  "LocalVolumes": "0",
  "Mounts": "",
  "Names": "myservice.1.gwbj2pzql8r6ovcyw2s61piyy",
  "Networks": "one",
  "Ports": "80/tcp",
  "RunningFor": "3 minutes ago",
  "Size": "0B",
  "Status": "Up 4 minutes"
}

The RunningFor, Size, and Status output should print the "raw" information as obtained from the container, and ID should show the un-truncated ID.

Perhaps not the best example, as RunningFor is a calculated value, but opening this for discussion.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the --format entry point used by docker ps and reproduce the JSON example from the issue. Compare the formatted and raw behavior for RunningFor, Size, Status, and ID; done requires an agreed definition of raw values and verification that JSON output preserves them.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.