如何查看每个Docker映像的Dockerfile? [英] How can I see Dockerfile for each docker image?

查看:3363
本文介绍了如何查看每个Docker映像的Dockerfile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下docker镜像。

I have the following docker images.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              48b5124b2768        2 months ago        1.84 kB
docker/whalesay     latest              6b362a9f73eb        22 months ago       247 MB

有没有办法可以在本地系统上看到每个docker映像的Dockerfile?

Is there a way I can see the Dockerfile of each docker image on my local system?

在哪里可以看到Docker映像的Dockerfile?不能帮到我,因为它不能完全显示Dockerfile,但是可以运行命令来创建映像。我想要Dockerfile本身。

The answer at Where to see the Dockerfile for a docker image? does not help me because it does not exactly show the Dockerfile but the commands run to create the image. I want the Dockerfile itself.

推荐答案

据我所知,不,您不能。因为Dockerfile用于构建映像,所以映像本身并未打包。这意味着您应该对其进行反向工程。您可以在图像或容器上使用 docker inspect ,从而获得一些了解并了解其配置方式。图像的图层也是可见的,因为在拖动特定图像时会拖动它们,所以这也不是秘密。

As far as I know, no, you can't. Because a Dockerfile is used for building the image, it is not packed with the image itself. That means you should reverse engineer it. You can use docker inspect on an image or container, thus getting some insight and a feel of how it is configured. The layers an image are also visible, since you pull them when you pull a specific image, so that is also no secret.

但是,您可以通常在Dockerhub上查看映像本身的存储库中的Dockerfile。我不能说大多数存储库都附加了Dockerfile,但是我看到的大多数存储库都有它。

However, you can usually see the Dockerfile in the repository of the image itself on Dockerhub. I can't say most repositories have Dockerfiles attached, but the most of the repositories I seen do have it.

不同的存储库维护者可能会选择不同的方式来记录Dockerfile。如果设置了自动构建,则可以在存储库页面上看到Dockerfile选项卡。但是,当有多个并行版本可用时(例如 Ubuntu ),维护人员通常会选择放置链接。说明中用于不同版本的Dockerfile。如果您在这里查看: https://hub.docker.com/_//ubuntu/,在支持的标签下(同样,对于Ubuntu),您可以看到每个Ubuntu版本都有指向多个Dockerfile的链接。

Different repository maintainers may opt for different ways to document the Dockerfiles. You can see the Dockerfile tab on the repository page if automatic builds are set up. But when multiple parallel versions are available (like for Ubuntu), maintainers usually opt to put links the Dockerfiles for different versions in the description. If you take a look here: https://hub.docker.com/_/ubuntu/, under the "Supported tags" (again, for Ubuntu), you can see there are links to multiple Dockerfiles, for each respective Ubuntu version.

这篇关于如何查看每个Docker映像的Dockerfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆