diff --git a/api_test.go b/api_test.go index bb8f08f93b..5096b05212 100644 --- a/api_test.go +++ b/api_test.go @@ -161,8 +161,8 @@ func TestGetImagesJson(t *testing.T) { t.Errorf("Excepted 1 image, %d found", len(images2)) } - if images2[0].Id != GetTestImage(runtime).ShortId() { - t.Errorf("Retrieved image Id differs, expected %s, received %s", GetTestImage(runtime).ShortId(), images2[0].Id) + if images2[0].Id != GetTestImage(runtime).Id { + t.Errorf("Retrieved image Id differs, expected %s, received %s", GetTestImage(runtime).Id, images2[0].Id) } r3 := httptest.NewRecorder() diff --git a/commands.go b/commands.go index 7a971d2d6d..4f1e7c5871 100644 --- a/commands.go +++ b/commands.go @@ -687,6 +687,7 @@ func CmdImages(args ...string) error { cmd := Subcmd("images", "[OPTIONS] [NAME]", "List images") quiet := cmd.Bool("q", false, "only show numeric IDs") all := cmd.Bool("a", false, "show all images") + noTrunc := cmd.Bool("notrunc", false, "Don't truncate output") flViz := cmd.Bool("viz", false, "output graph in graphviz format") if err := cmd.Parse(args); err != nil { @@ -737,9 +738,19 @@ func CmdImages(args ...string) error { } if !*quiet { - fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\n", out.Repository, out.Tag, out.Id, HumanDuration(time.Now().Sub(time.Unix(out.Created, 0)))) + fmt.Fprintf(w, "%s\t%s\t", out.Repository, out.Tag) + if *noTrunc { + fmt.Fprintf(w, "%s\t", out.Id) + } else { + fmt.Fprintf(w, "%s\t", TruncateId(out.Id)) + } + fmt.Fprintf(w, "%s ago\n", HumanDuration(time.Now().Sub(time.Unix(out.Created, 0)))) } else { - fmt.Fprintln(w, out.Id) + if *noTrunc { + fmt.Fprintln(w, out.Id) + } else { + fmt.Fprintln(w, TruncateId(out.Id)) + } } } diff --git a/server.go b/server.go index e04dfd008d..453574946d 100644 --- a/server.go +++ b/server.go @@ -161,7 +161,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) { delete(allImages, id) out.Repository = name out.Tag = tag - out.Id = image.ShortId() + out.Id = image.Id out.Created = image.Created.Unix() outs = append(outs, out) } @@ -170,7 +170,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) { if filter == "" { for _, image := range allImages { var out ApiImages - out.Id = image.ShortId() + out.Id = image.Id out.Created = image.Created.Unix() outs = append(outs, out) }