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


当前回答

如果图像包含一个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文件中。

其他回答

如果图像包含一个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 save nginx > nginx.tar
tar -xvf nginx.tar

有以下文件:

清单。json -描述具有Container属性的文件系统层和json文件的名称。 .json -容器属性 -每个“layerid”目录包含json文件,描述与该层相关的层属性和文件系统。Docker将容器映像存储为层,通过跨映像重用层来优化存储空间。

https://sreeninet.wordpress.com/2016/06/11/looking-inside-container-images/

OR

您可以使用dive与TUI交互查看图像内容

https://github.com/wagoodman/dive

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

anchore-cli image content myrepo/app:latest files

https://anchore.com/opensource/

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

这里公认的答案是有问题的,因为不能保证图像将具有任何类型的交互式外壳。例如,无人机/无人机图像包含在一个命令/无人机上,它也有一个ENTRYPOINT,所以这将失败:

$ docker run -it drone/drone sh
FATA[0000] DRONE_HOST is not properly configured        

这将会失败:

$ docker run --rm -it --entrypoint sh drone/drone
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"sh\": executable file not found in $PATH".

这不是一个不常见的配置;许多最小映像只包含支持目标服务所需的二进制文件。幸运的是,有一些不依赖于图像内容的机制用于探索图像文件系统。最简单的可能是docker export命令,它将容器文件系统导出为tar归档文件。因此,启动一个容器(它是否失败并不重要):

$ docker run -it drone/drone sh
FATA[0000] DRONE_HOST is not properly configured        

然后使用docker export将文件系统导出到tar:

$ docker export $(docker ps -lq) | tar tf -

docker ps -lq的意思是“给我最近的docker容器的id”。您可以用显式的容器名称或id替换它。

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

不需要特殊安装。

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