diff --git a/api_params.go b/api_params.go index 96a731c98f..9a689a04c3 100644 --- a/api_params.go +++ b/api_params.go @@ -7,13 +7,12 @@ type APIHistory struct { } type APIImages struct { - Repository string `json:",omitempty"` - Tag string `json:",omitempty"` - ID string `json:"Id"` - Created int64 - Size int64 - ParentSize int64 - + Repository string `json:",omitempty"` + Tag string `json:",omitempty"` + ID string `json:"Id"` + Created int64 + Size int64 + VirtualSize int64 } type APIInfo struct { @@ -28,11 +27,11 @@ type APIInfo struct { type APIContainers struct { ID string `json:"Id"` - Image string - Command string - Created int64 - Status string - Ports string + Image string + Command string + Created int64 + Status string + Ports string SizeRw int64 SizeRootFs int64 } diff --git a/commands.go b/commands.go index 1278892117..326a436ce2 100644 --- a/commands.go +++ b/commands.go @@ -812,8 +812,8 @@ func (cli *DockerCli) CmdImages(args ...string) error { fmt.Fprintf(w, "%s\t", utils.TruncateID(out.ID)) } fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0)))) - if out.ParentSize > 0 { - fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.Size), utils.HumanSize(out.ParentSize)) + if out.VirtualSize > 0 { + fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.Size), utils.HumanSize(out.VirtualSize)) } else { fmt.Fprintf(w, "%s\n", utils.HumanSize(out.Size)) } diff --git a/image.go b/image.go index f19667e7ec..8d4c42e733 100644 --- a/image.go +++ b/image.go @@ -31,7 +31,6 @@ type Image struct { Architecture string `json:"architecture,omitempty"` graph *Graph Size int64 - ParentSize int64 } func LoadImage(root string) (*Image, error) { @@ -376,13 +375,13 @@ func (img *Image) Checksum() (string, error) { return hash, nil } -func (img *Image) getVirtualSize(size int64) int64 { +func (img *Image) getParentsSize(size int64) int64 { parentImage, err := img.GetParent() if err != nil || parentImage == nil { return size } size += parentImage.Size - return parentImage.getVirtualSize(size) + return parentImage.getParentsSize(size) } // Build an Image object from raw json data diff --git a/server.go b/server.go index efd2850079..5e1459a861 100644 --- a/server.go +++ b/server.go @@ -177,7 +177,7 @@ func (srv *Server) Images(all bool, filter string) ([]APIImages, error) { out.ID = image.ID out.Created = image.Created.Unix() out.Size = image.Size - out.ParentSize = image.getVirtualSize(0) + out.VirtualSize = image.getParentsSize(0) + image.Size outs = append(outs, out) } } @@ -188,7 +188,7 @@ func (srv *Server) Images(all bool, filter string) ([]APIImages, error) { out.ID = image.ID out.Created = image.Created.Unix() out.Size = image.Size - out.ParentSize = image.getVirtualSize(0) + out.VirtualSize = image.getParentsSize(0) + image.Size outs = append(outs, out) } }