首页 > 解决方案 > How to check which version docker image is built upon

问题描述

I have a docker image sitting in Artifactory. How to check what is "base image version is"?

e.g. My dockerimage in artifactory created based on docker file like this

FROM test-image:v1.0.0
...

Now after the build, how can i find that this image is built on v1.0.0

I tried doing docker inspect <imagename> it didn't help me to find the version of test-image. Is there anyway I can find this version?

标签: docker

解决方案


您可以使用docker image history来查看图像所包含的文件系统层。

例如,假设您有一个名为app.

docker image history app

结果看起来像这样。

IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
7a85c25a7a6b        3 hours ago         /bin/sh -c #(nop)  CMD ["node" "index.js"]      0B                  
339d3cb45826        3 hours ago         /bin/sh -c #(nop) COPY dir:15f5040b90b2035eb…   471B                
d7c2ba41aed4        8 days ago          /bin/sh -c #(nop) WORKDIR /node/app             0B                  
da8751259bd7        8 days ago          /bin/sh -c #(nop)  EXPOSE 5000                  0B                  
25d4e098fa1b        8 days ago          /bin/sh -c #(nop)  ENV PORT=5000                0B                  
0e2e78467169        5 weeks ago         /bin/sh -c #(nop)  CMD ["node"]                 0B                  
<missing>           5 weeks ago         /bin/sh -c #(nop)  ENTRYPOINT ["docker-entry…   0B                  
<missing>           5 weeks ago         /bin/sh -c #(nop) COPY file:238737301d473041…   116B                
<missing>           5 weeks ago         /bin/sh -c set -ex   && savedAptMark="$(apt-…   9.58MB              
<missing>           5 weeks ago         /bin/sh -c #(nop)  ENV YARN_VERSION=1.22.4      0B                  
<missing>           5 weeks ago         /bin/sh -c ARCH= && dpkgArch="$(dpkg --print…   100MB               
<missing>           5 weeks ago         /bin/sh -c #(nop)  ENV NODE_VERSION=14.4.0      0B                  
<missing>           5 weeks ago         /bin/sh -c groupadd --gid 1000 node   && use…   333kB               
<missing>           5 weeks ago         /bin/sh -c #(nop)  CMD ["bash"]                 0B                  
<missing>           5 weeks ago         /bin/sh -c #(nop) ADD file:57b431451a292755d…   55.3MB 

查看 IMAGE 列和第一个正上方的条目<missing>,在本例中为 - 0e2e78467169。这是构建新图像的图像的 ID。现在您可以列出所有图像并找到相应的图像。

docker image ls | grep 0e2e78467169

示例输出:

node                         14-stretch-slim     0e2e78467169        5 weeks ago         165MB

这个 ( node:14-stretch-slim) 是我用来构建新图像的图像。


推荐阅读