我做了一个docker拉,可以列出下载的图像。我想看看这张照片的内容。在网上查了一下,但没有直接的答案。


当前回答

onlineer,不运行docker(基于上面的响应)

IMAGE=your_image docker create --name filelist $IMAGE command && docker export filelist | tar tf - | tree --fromfile . && docker rm filelist

相同,但是报告树结构到result.txt

IMAGE=your_image docker create --name filelist $IMAGE command && docker export filelist | tar tf - | tree --noreport --fromfile . | tee result.txt && docker rm filelist

其他回答

如果图像包含一个shell,您可以使用该图像运行一个交互式shell容器,并探索该图像所具有的任何内容。如果sh不可用,busybox ash shell可能可用。

例如:

docker run -it image_name sh

或者跟随带有入口点的图像

docker run -it --entrypoint sh image_name

或者,如果你想查看映像是如何构建的,也就是Dockerfile中的步骤,你可以:

docker image history --no-trunc image_name > image_history

这些步骤将被记录到image_history文件中。

如果你想在不启动容器的情况下列出镜像中的文件:

docker create --name listfiles <image name>
docker export listfiles | tar -t
docker rm listfiles

有一个叫做anchor - cli的免费开源工具可以用来扫描容器图像。这个命令将允许您列出容器映像中的所有文件

anchore-cli image content myrepo/app:latest files

https://anchore.com/opensource/

编辑:不再从anchore.com,这是一个python程序,你可以从https://github.com/anchore/anchore-cli安装

使用Docker EE for Windows (17.66.2 - EE -6 on Hyper-V Server 2016),可以在主机操作系统的C:\ProgramData\ Docker \windowsfilter\路径下检查Windows容器的所有内容。

不需要特殊安装。

文件夹前缀可以通过docker ps -a输出的容器id找到。

我试过这个工具——https://github.com/wagoodman/dive 我发现探索docker映像的内容非常有帮助。