Skip to content

add -tree option to images#1794

Merged
metalivedev merged 14 commits intomoby:masterfrom
justone:add-images-tree
Nov 7, 2013
Merged

add -tree option to images#1794
metalivedev merged 14 commits intomoby:masterfrom
justone:add-images-tree

Conversation

@justone
Copy link
Copy Markdown
Contributor

@justone justone commented Sep 4, 2013

This adds another option to images to print the image hierarchy in text form.

$ docker images -tree
|─27cf78414709
| └─b750fe79269d Tags: ubuntu:12.10,ubuntu:quantal
|   |─15fcc3627e79
|   | └─4b6446d47a37
|   |   └─0c074eec5f5c
|   |     └─3d546eda2db2
|   |       └─d660c80f5e1f
|   |         └─596fb3a686cf
|   |           └─61517a9129a2
|   |             └─3ad08d106530
|   |               └─64c0a2fd7c30
|   |                 └─1fde87bad242
|   |                   └─63b2b9368988
|   |                     └─fc4708bf64c3 Tags: ndj/mongodb:latest
|   |─3e11a97c3f82
|   | └─9dc7a7486e87
|   |   └─b179e38c4afd
|   |     └─b98d65ae00f7 Tags: shykes/znc:0.1,shykes/znc:git-eb9ffb538d1539c41efd03fa66c5ac1b8b91ca2a,shykes/znc:latest
|   └─8ee958cf9d12
|     └─adcb0fb35213
|       └─a6ddc80ec783
|         └─cc7feb9c3b51
|           └─b28ecfd506c6
|             └─37e7fb8b1be1
|               └─a22891c05c50
|                 └─cf9194b5b2b0
|                   └─564bac8b57aa
|                     └─e319e5b173bf
|                       └─c4551a6f0379
|                         └─b7bf889a949b
|                           └─ed37dbb60f27
|                             └─d210ec474616
|                               └─6311f2fa7ca9 Tags: ndj/redis:latest
|─8dbd9e392a96 Tags: ubuntu:12.04,ubuntu:latest,ubuntu:precise
| |─4df3eeb2c202
| | └─dd5498b6c712
| |   └─8d04c42f264e
| |     └─0c573a4b40cf
| |       └─a35fd99a7ea9
| |         └─dde68970d84b
| |           └─1822dc1f204e
| |             └─d45e5ba6dc2f
| |               └─d95940e2b97c
| |                 └─ee69859f33e8
| |                   └─29c4a226db51
| |                     └─df6178eb4c47
| |                       └─d809b136c558
| |                         └─0e19c79ffe35
| |                           └─86d4dd50dd90
| |                             └─aa6181c15178
| |                               └─c3fb316e3819
| |                                 └─f7ee6b773e3b
| |                                   └─c59ea12f6979
| |                                     └─e4e095dc03e5
| |                                       └─7e953d9b8602
| |                                         └─fb2759a6fbb5
| |                                           └─254835df9ccc
| |                                             └─e3fd1ccf8a1d
| |                                               └─115de9124bf2
| |                                                 └─3387c441027a
| |                                                   └─6bde376f8cc1 Tags: docker:latest
| └─d2d41694c20c
|   └─4cede2d58460
|     └─8d5d054f1376
|       └─5ade2d9ec9e0
|         └─76b0b1ab5fd5
|           └─ac3cca0eb14d
|             └─81acc6d83075
|               └─d31c015a3240
|                 └─c1c53577dc84
|                   └─2343dfdcc852
|                     └─95f9da0b614d
|                       └─2d6802031bf9
|                         └─b32035a894f2
|                           └─86858040aa36
|                             └─2ef244b028ac
|                               └─020b93c719a5 Tags: ndj/hipache:latest
└─e9aa60c60128 Tags: docker-ut:latest
$

This would (hopefully) solve #1776.

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Sep 4, 2013

The first commit is just the implementation. If the team likes it, I'll add tests and 'go fmt' it.

@crosbymichael
Copy link
Copy Markdown
Contributor

@justone Looks awesome.

One thing that does not work is if I run
docker images -tree <imageid>
I expect only the current images graph to be displayed.

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Sep 4, 2013

Ah, ok. I'll add that and some tests. Thanks.

@shykes
Copy link
Copy Markdown
Contributor

shykes commented Sep 5, 2013

This looks very cool and I would love to use it :)

My first thought is that it would make more sense to move the display logic to the client. It can probably use the existing JSON api routes to get all the data it needs, no?

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Sep 5, 2013

@crosbymichael I added the ability to specify a starting image.

@shykes I originally thought to put the logic on the client side, but I found that the logic for -viz is on the server side, so I put -tree there to be consistent.

Also, the JSON api route doesn't include parentage, so that would have to be added. Would it be ok to finish this implementation where it is and then open another PR to move both -tree and -viz to the client?

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Sep 5, 2013

@justone If it's not too much work, feel free to move, -viz client side among yours :)

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Sep 6, 2013

@vieux I think it won't be too much more work. If I add parentage to the JSON images API, would that require an API version bump?

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Sep 11, 2013

Nope, as we just released 1.5 it's ok

@srid
Copy link
Copy Markdown
Contributor

srid commented Sep 24, 2013

if you could also add a size column, showing the size of each image and also the virtual size including its ancestors, that'd be great.

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Sep 24, 2013

Good idea.

I do still plan on implementing this. Just had life get busy for a bit.

@crosbymichael
Copy link
Copy Markdown
Contributor

@justone Any update on this? Do you need any help?

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Oct 3, 2013

No update as of yet. Been catching up with the latest code over the past couple days and hope to have something this weekend.

@justone justone closed this Oct 6, 2013
@justone justone reopened this Oct 6, 2013
@justone
Copy link
Copy Markdown
Contributor Author

justone commented Oct 6, 2013

Oops, accidental close.

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Oct 6, 2013

Todo list for the rest of the pull request:

  • rework /images/json to include parentage and consolidate repo/tag
  • move -viz code from server to client
  • re-implement -tree code on client
  • add size to tree info
  • make sure all existing tests run
  • add tests for new code
  • update any documentation

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Oct 28, 2013

Alright, @shykes, @crosbymichael, and @vieux, this pull request is ready for review. I just rebased to master. All tests pass, except for TestPrivilegedCanMount, which fails on master too.

Could you take a look and let me know if there's anything I need to fix?

Thanks.

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Oct 31, 2013

@justone sorry, could you rebase this once again please ?

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Oct 31, 2013

@vieux No problem. Rebase done.

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Oct 31, 2013

LGTM, ping @crosbymichael

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Nov 5, 2013

ping @creack @crosbymichael

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Nov 6, 2013

Rebased again.

@creack
Copy link
Copy Markdown
Contributor

creack commented Nov 6, 2013

LGTM, /cc @metalivedev could you take a look at the doc?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is worth holding up the merge, but you removed viz from the API, so this sentence is incorrect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this up quick.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to the requirement that the Content-type header should be set to "application/tar". Is that no longer a requirement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's on line 984, below.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Thanks.

@metalivedev
Copy link
Copy Markdown
Contributor

Thanks for the quick fix on the images/viz!
The last tweak is to make the CLI documentation show -tree in the same way we show -viz:

.. _cli_images:

``images``
----------

::

    Usage: docker images [OPTIONS] [NAME]

    List images

      -a=false: show all images
      -q=false: only show numeric IDs
      -tree=false: output in text tree format
      -viz=false: output in graphviz format

@justone
Copy link
Copy Markdown
Contributor Author

justone commented Nov 6, 2013

Ok, I fixed up the cli.rst doc. Thanks for your reviewing.

@metalivedev
Copy link
Copy Markdown
Contributor

Docs LGTM. Thanks for the fixes!

metalivedev pushed a commit that referenced this pull request Nov 7, 2013
@metalivedev metalivedev merged commit 807a305 into moby:master Nov 7, 2013
@justone
Copy link
Copy Markdown
Contributor Author

justone commented Nov 7, 2013

Awesome! Thank you to everyone who reviewed this PR.

@justone justone deleted the add-images-tree branch November 7, 2013 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants