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

查看:40
本文介绍了如何查看每个 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?

在哪里可以看到 Dockerfile 的 Docker 映像的答案? 对我没有帮助,因为它没有完全显示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),维护人员通常选择将链接放在描述中不同版本的 Dockerfiles.如果你看看这里: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天全站免登陆