Merge pull request #30962 from TheHipbot/30431-implement-format-for-history-with-docs
30431 implement format for history with docs Upstream-commit: a3ab46361ee91dc99790e84369b4865572bd9f8c Component: engine
This commit is contained in:
@ -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 %}
|
||||
```
|
||||
Reference in New Issue
Block a user