67

I know docker has deprecated --tree flag from docker images command. But I could not find any handy command to get same output like docker images --tree. I found dockviz. But it seems to be another container to run. Is there any built in cli command to see tree view of images without using dockviz

Nur Rony
  • 7,823
  • 7
  • 38
  • 45

1 Answers1

104

Update Nov. 2021: for online public image, you have the online service contains.dev.

Update Nov. 2018, docker 18.09.
You now have wagoodman/dive, A tool for exploring each layer in a docker image

dive

To analyze a Docker image simply run dive with an image tag/id/digest:

dive <your-image-tag>

or if you want to build your image then jump straight into analyzing it:

dive build -t <some-tag> .

The current (Sept 2015, docker 1.8) workaround mentioned by issue 5001 remains dockviz indeed:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images -t

The -t allows to remain in CLI only (no graphics needed)


Update Sept. 2016 (post docker 1.10: docker 1.11 soon 1.12), one year later, as mentioned in the same issue 5001, by Michael Härtl:

Since 1.10 the way layer IDs worked has changed fundamentally. For a lengthy explanation of this topic see #20399. There's also #20451 but I'm not sure, if this could be used by the nate/dockviz image.

Personally I find the way the new layers work very very confusing and much less transparent than before. And it's not really well documented either.
AFAIK @tonistiigi's comments in the issue above are the only public explanation available.

Tõnis Tiigi:

Pre v1.10 there was no concept of layers or the other way to think about it is that every image only had one layer. You built a chain of images and you pushed and pulled a chain. All these images in the chain had their own config.

Now there is a concept of a layer that is a content addressable filesystem diff. Every image configuration has an array of layer references that make up the root filesystem of the image and no image requires anything from its parent to run. Push and pull only move a single image, the parent images are only generated for a local build to use for the cache.

If you build an image with the Dockerfile, every command adds a history item into the image configuration. This stores to command so you can see it in docker history. As this is part of image configuration it also moves with push/pull and is included in the checksum verification.

Here are some examples of content addressable configs:
https://gist.github.com/tonistiigi/6447977af6a5c38bbed8

Terms in v1.10: (the terms really have not changed in implementation but previously our docs probably simplified things).

  • Layer is a filesystem diff. Bunch of files that when stacked on top of each other make up a root filesystem. Layers are managed by graphdrivers, they don't know anything about images.
  • Image is something you can run and that shows up in docker images -a. Needs to have a configuration object. When container starts it needs some kind of way to generate a root filesystem from image info. On build every Dockerfile command creates a new image.

You can refer to the more recent project TomasTomecek/sen, which:

https://github.com/TomasTomecek/sen/raw/master/data/image-tree.gif

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I am getting this message: ```docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"images\": executable file not found in $PATH": unknown.``` – Ivan Aracki May 09 '18 at 10:54
  • @IvanAracki maybe because the docker sock was not properly shared? What exact command line did you type? On which OS? If the issue persists, it will have to be reported on https://github.com/justone/dockviz/issues – VonC May 09 '18 at 11:07
  • ```docker run --rm -v /var/run/docker.sock:/var/run/docker.sock apache/nifi:latest images -t``` on macOS – Ivan Aracki May 09 '18 at 11:18
  • @IvanAracki Then it seems to make sense: images is only working with `nate/dockviz`, not xxx/yyy. https://hub.docker.com/r/apache/nifi/ is not meant to run 'images'. – VonC May 09 '18 at 11:20
  • @VonC, how do i get `dive` in the first place. I mean it seems to like a command, so how do i obtain this command `dive` –  Oct 06 '20 at 18:43
  • ?? `docker pull wagoodman/dive` seems to be the way to go... tx –  Oct 06 '20 at 18:48
  • @joveny Yes, that is one way. Or you can rebuild it locally. All the possible installations are listed at https://github.com/wagoodman/dive#installation – VonC Oct 06 '20 at 18:51
  • Thanks @VonC, I was looking at the top of the document. Should have scrolled a little bit down. :-) –  Oct 06 '20 at 19:05