gpt4 book ai didi

docker - 如何查看 docker 图像的 TreeView ?

转载 作者:IT老高 更新时间:2023-10-28 12:35:15 26 4
gpt4 key购买 nike

我知道 docker 已弃用 docker images 命令中的 --tree 标志。但是我找不到任何方便的命令来获得像 docker images --tree 这样的相同输出。我找到了 dockviz .但它似乎是另一个要运行的容器。是否有任何内置的 cli 命令可以在不使用 dockviz

的情况下查看图像的 TreeView

最佳答案

2021 年 11 月更新:在线公众形象,您有在线服务 contains.dev

2018 年 11 月更新,docker 18.09。
你现在有了 wagoodman/dive ,一个探索 docker 镜像中每一层的工具

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> .

issue 5001 提到的当前(2015 年 9 月,docker 1.8)解决方法确实仍然是 dockviz:

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

-t 只允许保留在 CLI 中(不需要图形)


2016 年 9 月更新(发布 docker 1.10:docker 1.11 很快 1.12),一年后,如 same issue 5001 中所述,由 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.
  • 图像是您可以运行的东西,它会显示在 docker images -a 中。需要有一个配置对象。当容器启动时,它需要某种方式从图像信息生成根文件系统。在构建时,每个 Dockerfile 命令都会创建一个新镜像。

您可以引用最近的项目 TomasTomecek/sen ,其中:

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

关于docker - 如何查看 docker 图像的 TreeView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32454679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com