Do not display size and virtual size on the cli.
Only display virtual size on the cli
| ... | ... |
@@ -1200,7 +1200,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
| 1200 | 1200 |
|
| 1201 | 1201 |
w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) |
| 1202 | 1202 |
if !*quiet {
|
| 1203 |
- fmt.Fprintln(w, "REPOSITORY\tTAG\tIMAGE ID\tCREATED\tSIZE") |
|
| 1203 |
+ fmt.Fprintln(w, "REPOSITORY\tTAG\tIMAGE ID\tCREATED\tVIRTUAL SIZE") |
|
| 1204 | 1204 |
} |
| 1205 | 1205 |
|
| 1206 | 1206 |
for _, out := range outs {
|
| ... | ... |
@@ -1213,12 +1213,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
| 1213 | 1213 |
} |
| 1214 | 1214 |
|
| 1215 | 1215 |
if !*quiet {
|
| 1216 |
- fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t", repo, tag, out.ID, utils.HumanDuration(time.Now().UTC().Sub(time.Unix(out.Created, 0)))) |
|
| 1217 |
- if out.VirtualSize > 0 {
|
|
| 1218 |
- fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.Size), utils.HumanSize(out.VirtualSize)) |
|
| 1219 |
- } else {
|
|
| 1220 |
- fmt.Fprintf(w, "%s\n", utils.HumanSize(out.Size)) |
|
| 1221 |
- } |
|
| 1216 |
+ fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", repo, tag, out.ID, utils.HumanDuration(time.Now().UTC().Sub(time.Unix(out.Created, 0))), utils.HumanSize(out.VirtualSize)) |
|
| 1222 | 1217 |
} else {
|
| 1223 | 1218 |
fmt.Fprintln(w, out.ID) |
| 1224 | 1219 |
} |
| ... | ... |
@@ -237,8 +237,8 @@ Simple commit of an existing container |
| 237 | 237 |
$ docker commit c3f279d17e0a SvenDowideit/testimage:version3 |
| 238 | 238 |
f5283438590d |
| 239 | 239 |
$ docker images | head |
| 240 |
- REPOSITORY TAG ID CREATED SIZE |
|
| 241 |
- SvenDowideit/testimage version3 f5283438590d 16 seconds ago 204.2 MB (virtual 335.7 MB) |
|
| 240 |
+ REPOSITORY TAG ID CREATED VIRTUAL SIZE |
|
| 241 |
+ SvenDowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB |
|
| 242 | 242 |
|
| 243 | 243 |
|
| 244 | 244 |
Full -run example |
| ... | ... |
@@ -481,16 +481,16 @@ Listing the most recently created images |
| 481 | 481 |
.. code-block:: bash |
| 482 | 482 |
|
| 483 | 483 |
$ sudo docker images | head |
| 484 |
- REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 485 |
- <none> <none> 77af4d6b9913 19 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 486 |
- committest latest b6fa739cedf5 19 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 487 |
- <none> <none> 78a85c484f71 19 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 488 |
- docker latest 30557a29d5ab 20 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 489 |
- <none> <none> 0124422dd9f9 20 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 490 |
- <none> <none> 18ad6fad3402 22 hours ago 23.68 MB (virtual 1.082 GB) |
|
| 491 |
- <none> <none> f9f1e26352f0 23 hours ago 30.46 MB (virtual 1.089 GB) |
|
| 492 |
- tryout latest 2629d1fa0b81 23 hours ago 16.4 kB (virtual 131.5 MB) |
|
| 493 |
- <none> <none> 5ed6274db6ce 24 hours ago 30.44 MB (virtual 1.089 GB) |
|
| 484 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 485 |
+ <none> <none> 77af4d6b9913 19 hours ago 1.089 GB |
|
| 486 |
+ committest latest b6fa739cedf5 19 hours ago 1.089 GB |
|
| 487 |
+ <none> <none> 78a85c484f71 19 hours ago 1.089 GB |
|
| 488 |
+ docker latest 30557a29d5ab 20 hours ago 1.089 GB |
|
| 489 |
+ <none> <none> 0124422dd9f9 20 hours ago 1.089 GB |
|
| 490 |
+ <none> <none> 18ad6fad3402 22 hours ago 1.082 GB |
|
| 491 |
+ <none> <none> f9f1e26352f0 23 hours ago 1.089 GB |
|
| 492 |
+ tryout latest 2629d1fa0b81 23 hours ago 131.5 MB |
|
| 493 |
+ <none> <none> 5ed6274db6ce 24 hours ago 1.089 GB |
|
| 494 | 494 |
|
| 495 | 495 |
Listing the full length image IDs |
| 496 | 496 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| ... | ... |
@@ -498,16 +498,16 @@ Listing the full length image IDs |
| 498 | 498 |
.. code-block:: bash |
| 499 | 499 |
|
| 500 | 500 |
$ sudo docker images -notrunc | head |
| 501 |
- REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 502 |
- <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 503 |
- committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 504 |
- <none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 505 |
- docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 506 |
- <none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 30.53 MB (virtual 1.089 GB) |
|
| 507 |
- <none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 23.68 MB (virtual 1.082 GB) |
|
| 508 |
- <none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 30.46 MB (virtual 1.089 GB) |
|
| 509 |
- tryout latest 2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 16.4 kB (virtual 131.5 MB) |
|
| 510 |
- <none> <none> 5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 30.44 MB (virtual 1.089 GB) |
|
| 501 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 502 |
+ <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB |
|
| 503 |
+ committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB |
|
| 504 |
+ <none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB |
|
| 505 |
+ docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB |
|
| 506 |
+ <none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB |
|
| 507 |
+ <none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB |
|
| 508 |
+ <none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB |
|
| 509 |
+ tryout latest 2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB |
|
| 510 |
+ <none> <none> 5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB |
|
| 511 | 511 |
|
| 512 | 512 |
Displaying images visually |
| 513 | 513 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| ... | ... |
@@ -94,11 +94,25 @@ func (graph *Graph) Get(name string) (*Image, error) {
|
| 94 | 94 |
return nil, fmt.Errorf("Image stored at '%s' has wrong id '%s'", id, img.ID)
|
| 95 | 95 |
} |
| 96 | 96 |
img.graph = graph |
| 97 |
- if img.Size == 0 {
|
|
| 98 |
- size, err := utils.TreeSize(rootfs) |
|
| 99 |
- if err != nil {
|
|
| 100 |
- return nil, fmt.Errorf("Error computing size of rootfs %s: %s", img.ID, err)
|
|
| 97 |
+ |
|
| 98 |
+ if img.Size < 0 {
|
|
| 99 |
+ var size int64 |
|
| 100 |
+ if img.Parent == "" {
|
|
| 101 |
+ if size, err = utils.TreeSize(rootfs); err != nil {
|
|
| 102 |
+ return nil, err |
|
| 103 |
+ } |
|
| 104 |
+ } else {
|
|
| 105 |
+ parentFs, err := graph.driver.Get(img.Parent) |
|
| 106 |
+ if err != nil {
|
|
| 107 |
+ return nil, err |
|
| 108 |
+ } |
|
| 109 |
+ changes, err := archive.ChangesDirs(rootfs, parentFs) |
|
| 110 |
+ if err != nil {
|
|
| 111 |
+ return nil, err |
|
| 112 |
+ } |
|
| 113 |
+ size = archive.ChangesSize(rootfs, changes) |
|
| 101 | 114 |
} |
| 115 |
+ |
|
| 102 | 116 |
img.Size = size |
| 103 | 117 |
if err := img.SaveSize(graph.imageRoot(id)); err != nil {
|
| 104 | 118 |
return nil, err |
| ... | ... |
@@ -51,6 +51,9 @@ func LoadImage(root string) (*Image, error) {
|
| 51 | 51 |
if !os.IsNotExist(err) {
|
| 52 | 52 |
return nil, err |
| 53 | 53 |
} |
| 54 |
+ // If the layersize file does not exist then set the size to a negative number |
|
| 55 |
+ // because a layer size of 0 (zero) is valid |
|
| 56 |
+ img.Size = -1 |
|
| 54 | 57 |
} else {
|
| 55 | 58 |
size, err := strconv.Atoi(string(buf)) |
| 56 | 59 |
if err != nil {
|
| ... | ... |
@@ -104,30 +107,29 @@ func StoreImage(img *Image, jsonData []byte, layerData archive.Archive, root, la |
| 104 | 104 |
if err != nil {
|
| 105 | 105 |
return err |
| 106 | 106 |
} |
| 107 |
- if size = archive.ChangesSize(layer, changes); err != nil {
|
|
| 108 |
- return err |
|
| 109 |
- } |
|
| 107 |
+ size = archive.ChangesSize(layer, changes) |
|
| 110 | 108 |
} |
| 111 | 109 |
} |
| 112 | 110 |
} |
| 113 | 111 |
|
| 114 |
- // If raw json is provided, then use it |
|
| 115 |
- if jsonData != nil {
|
|
| 116 |
- return ioutil.WriteFile(jsonPath(root), jsonData, 0600) |
|
| 117 |
- } |
|
| 118 |
- // Otherwise, unmarshal the image |
|
| 119 |
- if jsonData, err = json.Marshal(img); err != nil {
|
|
| 120 |
- return err |
|
| 121 |
- } |
|
| 122 |
- if err := ioutil.WriteFile(jsonPath(root), jsonData, 0600); err != nil {
|
|
| 123 |
- return err |
|
| 124 |
- } |
|
| 125 |
- |
|
| 126 | 112 |
img.Size = size |
| 127 | 113 |
if err := img.SaveSize(root); err != nil {
|
| 128 | 114 |
return err |
| 129 | 115 |
} |
| 130 | 116 |
|
| 117 |
+ // If raw json is provided, then use it |
|
| 118 |
+ if jsonData != nil {
|
|
| 119 |
+ if err := ioutil.WriteFile(jsonPath(root), jsonData, 0600); err != nil {
|
|
| 120 |
+ return err |
|
| 121 |
+ } |
|
| 122 |
+ } else {
|
|
| 123 |
+ if jsonData, err = json.Marshal(img); err != nil {
|
|
| 124 |
+ return err |
|
| 125 |
+ } |
|
| 126 |
+ if err := ioutil.WriteFile(jsonPath(root), jsonData, 0600); err != nil {
|
|
| 127 |
+ return err |
|
| 128 |
+ } |
|
| 129 |
+ } |
|
| 131 | 130 |
return nil |
| 132 | 131 |
} |
| 133 | 132 |
|
| ... | ... |
@@ -871,7 +871,7 @@ func TestImagesTree(t *testing.T) {
|
| 871 | 871 |
"(?m) └─[0-9a-f]+.*", |
| 872 | 872 |
"(?m) └─[0-9a-f]+.*", |
| 873 | 873 |
"(?m) └─[0-9a-f]+.*", |
| 874 |
- fmt.Sprintf("(?m)^ └─%s Size: \\d+.\\d+ MB \\(virtual \\d+.\\d+ MB\\) Tags: test:latest", utils.TruncateID(image.ID)),
|
|
| 874 |
+ fmt.Sprintf("(?m)^ └─%s Size: \\d+ B \\(virtual \\d+.\\d+ MB\\) Tags: test:latest", utils.TruncateID(image.ID)),
|
|
| 875 | 875 |
} |
| 876 | 876 |
|
| 877 | 877 |
compiledRegexps := []*regexp.Regexp{}
|