| ... | ... |
@@ -788,7 +788,10 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
|
| 788 | 788 |
} |
| 789 | 789 |
|
| 790 | 790 |
func (cli *DockerCli) CmdHistory(args ...string) error {
|
| 791 |
- cmd := Subcmd("history", "IMAGE", "Show the history of an image")
|
|
| 791 |
+ cmd := Subcmd("history", "[OPTIONS] IMAGE", "Show the history of an image")
|
|
| 792 |
+ quiet := cmd.Bool("q", false, "only show numeric IDs")
|
|
| 793 |
+ noTrunc := cmd.Bool("notrunc", false, "Don't truncate output")
|
|
| 794 |
+ |
|
| 792 | 795 |
if err := cmd.Parse(args); err != nil {
|
| 793 | 796 |
return nil |
| 794 | 797 |
} |
| ... | ... |
@@ -807,14 +810,35 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
|
| 807 | 807 |
if err != nil {
|
| 808 | 808 |
return err |
| 809 | 809 |
} |
| 810 |
+ |
|
| 810 | 811 |
w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) |
| 811 |
- fmt.Fprintln(w, "ID\tCREATED\tCREATED BY") |
|
| 812 |
+ if !*quiet {
|
|
| 813 |
+ fmt.Fprintln(w, "ID\tCREATED\tCREATED BY\tSIZE") |
|
| 814 |
+ } |
|
| 812 | 815 |
|
| 813 | 816 |
for _, out := range outs {
|
| 814 |
- if out.Tags != nil {
|
|
| 815 |
- out.ID = out.Tags[0] |
|
| 817 |
+ if !*quiet {
|
|
| 818 |
+ if *noTrunc {
|
|
| 819 |
+ fmt.Fprintf(w, "%s\t", out.ID) |
|
| 820 |
+ } else {
|
|
| 821 |
+ fmt.Fprintf(w, "%s\t", utils.TruncateID(out.ID)) |
|
| 822 |
+ } |
|
| 823 |
+ |
|
| 824 |
+ fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0)))) |
|
| 825 |
+ |
|
| 826 |
+ if *noTrunc {
|
|
| 827 |
+ fmt.Fprintf(w, "%s\t", out.CreatedBy) |
|
| 828 |
+ } else {
|
|
| 829 |
+ fmt.Fprintf(w, "%s\t", utils.Trunc(out.CreatedBy, 45)) |
|
| 830 |
+ } |
|
| 831 |
+ fmt.Fprintf(w, "%s\n", utils.HumanSize(out.Size)) |
|
| 832 |
+ } else {
|
|
| 833 |
+ if *noTrunc {
|
|
| 834 |
+ fmt.Fprintln(w, out.ID) |
|
| 835 |
+ } else {
|
|
| 836 |
+ fmt.Fprintln(w, utils.TruncateID(out.ID)) |
|
| 837 |
+ } |
|
| 816 | 838 |
} |
| 817 |
- fmt.Fprintf(w, "%s \t%s ago\t%s\n", out.ID, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.CreatedBy) |
|
| 818 | 839 |
} |
| 819 | 840 |
w.Flush() |
| 820 | 841 |
return nil |
| ... | ... |
@@ -320,10 +320,11 @@ func (srv *Server) ImageHistory(name string) ([]APIHistory, error) {
|
| 320 | 320 |
outs := []APIHistory{} //produce [] when empty instead of 'null'
|
| 321 | 321 |
err = image.WalkHistory(func(img *Image) error {
|
| 322 | 322 |
var out APIHistory |
| 323 |
- out.ID = srv.runtime.repositories.ImageName(img.ShortID()) |
|
| 323 |
+ out.ID = img.ID |
|
| 324 | 324 |
out.Created = img.Created.Unix() |
| 325 | 325 |
out.CreatedBy = strings.Join(img.ContainerConfig.Cmd, " ") |
| 326 | 326 |
out.Tags = lookupMap[img.ID] |
| 327 |
+ out.Size = img.Size |
|
| 327 | 328 |
outs = append(outs, out) |
| 328 | 329 |
return nil |
| 329 | 330 |
}) |