本文最后更新于 328 天前,其中的信息可能已经有所发展或是发生改变。
有时候因为自己构建镜像的 Dockerfile 文件丢失,或者从网上下载的 Docker 镜像,想了解其镜像构建的步骤,这时候怎么办了?可通过以下两种方法获取。
# 顺便提一下,Rocky Linux 也有 Docker 镜像哦
❯ docker pull rockylinux/rocky-toolbox:9
# 方法一
❯ docker history rockylinux/rocky-toolbox:9
IMAGE CREATED CREATED BY SIZE COMMENT
ab7dfed87582 37 hours ago /bin/sh -c #(nop) CMD /bin/sh 309MB FROM docker.io/library/rockylinux:9
<missing> 37 hours ago /bin/sh -c dnf clean all 0B
<missing> 37 hours ago /bin/sh -c rm /extra-packages 0B
<missing> 37 hours ago /bin/sh -c dnf -y install $(<extra-packages) 0B
<missing> 37 hours ago /bin/sh -c #(nop) COPY file:ed241a206672b4f1… 0B
<missing> 37 hours ago /bin/sh -c rm /missing-docs 0B
<missing> 37 hours ago /bin/sh -c dnf -y reinstall $(<missing-docs) 0B
<missing> 37 hours ago /bin/sh -c #(nop) COPY file:bf19b43f85a7bbd9… 0B
<missing> 37 hours ago /bin/sh -c dnf -y update 0B
<missing> 37 hours ago /bin/sh -c sed -i '/tsflags=nodocs/d' /etc/d… 0B
<missing> 37 hours ago /bin/sh -c #(nop) COPY file:b1da0728c04ba266… 0B
<missing> 37 hours ago /bin/sh -c #(nop) LABEL com.github.container… 0B
# 方法二
❯ alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage"
# 查看相关镜像的构建命令
❯ dfimage -sV=1.36 rockylinux/rocky-toolbox:9 at 21:21:54 100%
Analyzing rockylinux/rocky-toolbox:9
Docker Version:
GraphDriver: overlay2
Environment Variables
|PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Image user
|User is root
Potential secrets:
|Found match etc/ssh/ssh_config Client SSH Config .?ssh_config[\s\S]* ab51801f1a3b22f130cf29e6261096ea4e3db66cda8472b4317967ca1d103f57/layer.tar
|Found match etc/ssh/ssh_config.d Client SSH Config .?ssh_config[\s\S]* ab51801f1a3b22f130cf29e6261096ea4e3db66cda8472b4317967ca1d103f57/layer.tar
|Found match etc/ssh/ssh_config.d/50-redhat.conf Client SSH Config .?ssh_config[\s\S]* ab51801f1a3b22f130cf29e6261096ea4e3db66cda8472b4317967ca1d103f57/layer.tar
|Found match root/.ssh SSH file \.ssh$ ab51801f1a3b22f130cf29e6261096ea4e3db66cda8472b4317967ca1d103f57/layer.tar
|Found match var/lib/dnf/history.sqlite Database file \.sqlite$ ab51801f1a3b22f130cf29e6261096ea4e3db66cda8472b4317967ca1d103f57/layer.tar
|Found match var/lib/rpm/rpmdb.sqlite Database file \.sqlite$ ab51801f1a3b22f130cf29e6261096ea4e3db66cda8472b4317967ca1d103f57/layer.tar
Dockerfile:
COPY file:b1da0728c04ba266a0e6590f8f297d999a29954b4ea207b879ba8eef062eab1f in /
RUN sed -i '/tsflags=nodocs/d' /etc/dnf/dnf.conf
RUN dnf -y update
COPY file:bf19b43f85a7bbd9684355acd9cb82fd9c1e2772f3e36b94f0eec8a95e868c18 in /
RUN dnf -y reinstall $(<missing-docs)
RUN rm /missing-docs
COPY file:ed241a206672b4f140fc843c2da283e997479fb6a5f30744289e1c6d713c606f in /
RUN dnf -y install $(<extra-packages)
RUN rm /extra-packages
RUN dnf clean all
CMD /bin/sh
版权声明:「自由转载-保持署名-非商业性使用-禁止演绎 3.0 国际」(CC BY-NC-ND 3.0)
用一杯咖啡支持我们,我们的每一篇[文档]都经过实际操作和精心打磨,而不是简单地从网上复制粘贴。期间投入了大量心血,只为能够真正帮助到您。
暂无评论