In docker, how do I know which image belongs to a

2019-12-16 21:34发布

Im very new to docker but have a question.

Suppose I have 50 images, which I can see from

> docker images

p25235 
1566 
p6462263
etc...

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
1条回答
孤傲高冷的网名
2楼-- · 2019-12-16 22:06

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>

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          

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.

查看更多
登录 后发表回答