diff --git a/api/client/history.go b/api/client/history.go index 4ac46d92ce..79c6f3f7a6 100644 --- a/api/client/history.go +++ b/api/client/history.go @@ -18,6 +18,7 @@ import ( // Usage: docker history [OPTIONS] IMAGE func (cli *DockerCli) CmdHistory(args ...string) error { cmd := cli.Subcmd("history", "IMAGE", "Show the history of an image", true) + human := cmd.Bool([]string{"H", "-human"}, true, "Print sizes and dates in human readable format") quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") cmd.Require(flag.Exact, 1) @@ -46,14 +47,24 @@ func (cli *DockerCli) CmdHistory(args ...string) error { fmt.Fprintf(w, stringid.TruncateID(entry.ID)) } if !*quiet { - fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0)))) + if *human { + fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0)))) + } else { + fmt.Fprintf(w, "\t%s\t", time.Unix(entry.Created, 0).Format(time.RFC3339)) + } if *noTrunc { fmt.Fprintf(w, "%s\t", entry.CreatedBy) } else { fmt.Fprintf(w, "%s\t", stringutils.Truncate(entry.CreatedBy, 45)) } - fmt.Fprintf(w, "%s\t", units.HumanSize(float64(entry.Size))) + + if *human { + fmt.Fprintf(w, "%s\t", units.HumanSize(float64(entry.Size))) + } else { + fmt.Fprintf(w, "%d\t", entry.Size) + } + fmt.Fprintf(w, "%s", entry.Comment) } fmt.Fprintf(w, "\n") diff --git a/docs/man/docker-history.1.md b/docs/man/docker-history.1.md index 2b38d83e67..268e378d06 100644 --- a/docs/man/docker-history.1.md +++ b/docs/man/docker-history.1.md @@ -19,6 +19,9 @@ Show the history of when and how an image was created. **--help** Print usage statement +**-H**. **--human**=*true*|*false* + Print sizes and dates in human readable format. The default is *true*. + **--no-trunc**=*true*|*false* Don't truncate output. The default is *false*. diff --git a/docs/sources/reference/commandline/cli.md b/docs/sources/reference/commandline/cli.md index 986c0d45fb..88250f7625 100644 --- a/docs/sources/reference/commandline/cli.md +++ b/docs/sources/reference/commandline/cli.md @@ -1222,6 +1222,7 @@ This will create a new Bash session in the container `ubuntu_bash`. Show the history of an image + -H, --human=true Print sizes and dates in human readable format --no-trunc=false Don't truncate output -q, --quiet=false Only show numeric IDs