mirror of https://github.com/docker/cli.git
Implements --format option for docker history command by creating a formatter
Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Adds to history documentation for --format Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Adds MarshalJSON to historyContext for {{json .}} format Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Adds back the --human option to history command Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Cleans up formatter around --human option for history, Adds integration test for --format option of history Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Adds test for history formatter checking full table results, Runs go fmt on touched files Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Fixes lint errors in formatter/history Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Runs go fmt on cli/command/formatter/history.go Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> sRemoves integration test for --format option of history Merges Created and CreatedSince in docker history formatter, Updates docs and tests
This commit is contained in:
parent
9e2467d474
commit
aa124aee73
|
@ -21,10 +21,11 @@ Usage: docker history [OPTIONS] IMAGE
|
|||
Show the history of an image
|
||||
|
||||
Options:
|
||||
--help Print usage
|
||||
-H, --human Print sizes and dates in human readable format (default true)
|
||||
--no-trunc Don't truncate output
|
||||
-q, --quiet Only show numeric IDs
|
||||
--format string Pretty-print images using a Go template
|
||||
--help Print usage
|
||||
-H, --human Print sizes and dates in human readable format (default true)
|
||||
--no-trunc Don't truncate output
|
||||
-q, --quiet Only show numeric IDs
|
||||
```
|
||||
|
||||
|
||||
|
@ -54,3 +55,42 @@ IMAGE CREATED CREATED BY
|
|||
c69cab00d6ef 5 months ago /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar 0 B
|
||||
511136ea3c5a 19 months ago 0 B Imported from -
|
||||
```
|
||||
|
||||
### Format the output
|
||||
|
||||
The formatting option (`--format`) will pretty print history output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| Placeholder | Description|
|
||||
| ---- | ---- |
|
||||
| `.ID` | Image ID |
|
||||
| `.CreatedSince` | Elapsed time since the image was created if --human=true, otherwise timestamp of when image was created |
|
||||
| `.CreatedAt` | Timestamp of when image was created |
|
||||
| `.CreatedBy` | Command that was used to create the image |
|
||||
| `.Size` | Image disk size |
|
||||
| `.Comment` | Comment for image |
|
||||
|
||||
When using the `--format` option, the `history` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
`table` directive, will include column headers as well.
|
||||
|
||||
The following example uses a template without headers and outputs the
|
||||
`ID` and `CreatedSince` entries separated by a colon for all images:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker images --format "{{.ID}}: {{.Created}} ago"
|
||||
|
||||
cc1b61406712: 2 weeks ago
|
||||
<missing>: 2 weeks ago
|
||||
<missing>: 2 weeks ago
|
||||
<missing>: 2 weeks ago
|
||||
<missing>: 2 weeks ago
|
||||
<missing>: 3 weeks ago
|
||||
<missing>: 3 weeks ago
|
||||
<missing>: 3 weeks ago
|
||||
|
||||
{% endraw %}
|
||||
```
|
Loading…
Reference in New Issue