在docker中,我如何知道哪个图像属于给定源? [英] In docker, how do I know which image belongs to a given source?

查看:78
本文介绍了在docker中,我如何知道哪个图像属于给定源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是docker的新手,但有一个问题。

Im very new to docker but have a question.

假设我有50张图像,我可以从中看到

Suppose I have 50 images, which I can see from

> docker images

p25235 
1566 
p6462263
etc...

和文件夹中的50个项目,我可以从

and 50 projects in folders, which I can see from

> ls -la

project1
project2
project3
...etc

有没有一种方法(快速|轻松地)确定哪个图像与哪个项目相关?

Is there a way to (quickly | easily) tell which image is associated with which project?

推荐答案

Docker映像包括其构建历史,与Dockerfile中的命令以及镜像已生成的所有Dockerfile

Docker images include the their build history which line up with the commands in your Dockerfile, as well as any Dockerfiles the image was built FROM.

docker history <image>

哪个层以相反的顺序输出到Dockerfile,所以最后一个命令位于顶部。

Which outputs each layer in the opposite order to your Dockerfile, so the final command is at the top.

IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
aa04370cd0c1        4 weeks ago         /bin/sh -c #(nop)  CMD ["-c" "/etc/apt-cacher   0 B                 
ff0286e20caa        4 weeks ago         /bin/sh -c #(nop)  ENTRYPOINT ["/usr/sbin/apt   0 B                 
491d08e75e82        4 weeks ago         /bin/sh -c #(nop)  VOLUME [/var/cache/apt-cac   0 B                 
66e9f89cab13        4 weeks ago         /bin/sh -c #(nop)  EXPOSE 3142/tcp              0 B                 
9cc110ba4de6        4 weeks ago         /bin/sh -c #(nop) COPY file:dfc25768a29b1c296   38 B                
0df0917c94dd        4 weeks ago         /bin/sh -c #(nop) COPY file:0c3cad42682758b40   3.261 kB            
f0b1119fd676        5 weeks ago         /bin/sh -c set -uex;     apt-get update -y;     15.95 MB            
ddf73f48a05d        5 weeks ago         /bin/sh -c #(nop)  CMD ["/bin/bash"]            0 B                 
<missing>           5 weeks ago         /bin/sh -c #(nop) ADD file:c6c23585ab140b0b32   123 MB          

分隔多个相同Dockerfile的映像会有点困难,因为通常只有映像的校验和和构建步骤会更改,除非您将某种类型的版本元数据注入到构建中。

Separating multiple images of the same Dockerfile is a bit harder as normally only the checksums for the image and the build steps will change, unless you have some type of version metadata that is injected into the build.

这篇关于在docker中,我如何知道哪个图像属于给定源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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