使用dfimage工具从Docker镜像提取Dockerfile
有时候因为自己构建镜像的 Dockerfile 文件丢失,或者从网上下载的 Docker 镜像,想了解其镜像构建的步骤,这时候怎么办了?可通过以下两种方法获取。
方法一
使用docker history
命令
[root@localhost ~]# docker history ibmcom/mq:latest
IMAGE CREATED CREATED BY SIZE COMMENT
5211ea6323b7 18 months ago /bin/sh -c #(nop) LABEL version=9.2.4.0 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL vcs-url=git@github.… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL vcs-type=git 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL vcs-ref=1f6d37afedb… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL run=docker run -d -… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL release=r1 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL name=ibm-mqadvanced… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL build-date=2021-11-… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL architecture=amd64 0B
<missing> 18 months ago /bin/sh -c #(nop) ENTRYPOINT ["runmqdevserv… 0B
<missing> 18 months ago /bin/sh -c #(nop) USER 1001 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQS_PERMIT_UNKNOWN_ID… 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQ_CONNAUTH_USE_HTP=t… 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV LD_LIBRARY_PATH=/opt/… 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQ_ENABLE_EMBEDDED_WE… 0B
<missing> 18 months ago |3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 17.6MB
<missing> 18 months ago /bin/sh -c #(nop) COPY dir:314872ec79916fd02… 1.83kB
<missing> 18 months ago /bin/sh -c #(nop) COPY multi:dddbd8622bcb090… 7.05kB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:01dd6f8df223f9ef… 4.33MB
<missing> 18 months ago |3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 0B
<missing> 18 months ago |3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 10.8MB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:749c034e86ef1090… 1.26kB
<missing> 18 months ago |3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 131B
<missing> 18 months ago /bin/sh -c #(nop) COPY file:f6cedf077e8dfc3e… 131B
<missing> 18 months ago /bin/sh -c #(nop) COPY file:14e173f3dfb278eb… 268B
<missing> 18 months ago /bin/sh -c #(nop) COPY file:d16dbd18619fbb2f… 22.7kB
<missing> 18 months ago /bin/sh -c #(nop) USER 0 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL base-image-release=… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL base-image=registry… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL io.k8s.description=… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL io.k8s.display-name… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL io.openshift.tags=m… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL url=https://www.ibm… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL authoritative-sourc… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL distribution-scope=… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL vendor=IBM 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL description=Simplif… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL summary=IBM MQ Adva… 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQ_DEV=true 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG GO_WORKDIR 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG BASE_TAG 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG BASE_IMAGE 0B
<missing> 18 months ago /bin/sh -c #(nop) ENTRYPOINT ["runmqserver"] 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQ_CONNAUTH_USE_HTP=f… 0B
<missing> 18 months ago /bin/sh -c #(nop) USER 1001 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV LANG=en_US.UTF-8 AMQ_… 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQ_GRACE_PERIOD=30 0B
<missing> 18 months ago /bin/sh -c #(nop) ENV MQ_OVERRIDE_DATA_PATH… 0B
<missing> 18 months ago /bin/sh -c #(nop) EXPOSE 1414 9157 9443 0B
<missing> 18 months ago |4 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 21.5MB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:4d5d9772edf00f4b… 745B
<missing> 18 months ago /bin/sh -c #(nop) COPY dir:b7af534eda9621b0d… 3.96kB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:fb55849aee5e85c2… 591B
<missing> 18 months ago /bin/sh -c #(nop) COPY file:edebb47000f2e6c3… 810kB
<missing> 18 months ago /bin/sh -c #(nop) COPY multi:e47f2c08f045440… 8.31MB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:084bc89afdba5aa4… 13.2MB
<missing> 18 months ago |4 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 0B
<missing> 18 months ago |4 BASE_IMAGE=registry.redhat.io/ubi8/ubi-mi… 749MB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:163d9dc38f595e70… 3.04kB
<missing> 18 months ago /bin/sh -c #(nop) COPY file:74de0b85048a852b… 3.75kB
<missing> 18 months ago /bin/sh -c #(nop) LABEL base-image-release=… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL base-image=registry… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL io.k8s.description=… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL io.k8s.display-name… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL io.openshift.tags=m… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL url=https://www.ibm… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL authoritative-sourc… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL distribution-scope=… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL maintainer=IBM 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL vendor=IBM 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL description=Simplif… 0B
<missing> 18 months ago /bin/sh -c #(nop) LABEL summary=IBM MQ Adva… 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG GO_WORKDIR 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG BASE_TAG 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG BASE_IMAGE 0B
<missing> 18 months ago /bin/sh -c #(nop) ARG MQ_URL 0B
<missing> 18 months ago 4.65kB
<missing> 18 months ago 103MB Imported from -
方法二
使用alpine/dfimage
镜像工具,查看相关镜像的构建命令
它将自动提取目标docker镜像。参数-sV=1.36
并不总是必需的,只是指定镜像标签 。
如:dfimage -sV=1.36 ibmcom/mq:latest
[root@localhost ~]# alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage"
[root@localhost ~]# dfimage -sV=1.36 ibmcom/mq:latest
Analyzing ibmcom/mq:latest
Docker Version: 20.10.10
GraphDriver: overlay2
Environment Variables
|PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/mqm/bin
|container=oci
|MQ_OVERRIDE_DATA_PATH=/mnt/mqm/data
|MQ_OVERRIDE_INSTALLATION_NAME=Installation1
|MQ_USER_NAME=mqm
|MQ_GRACE_PERIOD=30
|LANG=en_US.UTF-8
|AMQ_DIAGNOSTIC_MSG_SEVERITY=1
|AMQ_ADDITIONAL_JSON_LOG=1
|LOG_FORMAT=basic
|MQ_CONNAUTH_USE_HTP=true
|MQ_DEV=true
|MQ_ENABLE_EMBEDDED_WEB_SERVER=1
|MQ_GENERATE_CERTIFICATE_HOSTNAME=localhost
|LD_LIBRARY_PATH=/opt/mqm/lib64
|MQS_PERMIT_UNKNOWN_ID=true
Open Ports
|9443
|1414
|9157
Image user
|Image is running as User: 1001
Potential secrets:
|Found match var/lib/dnf/history.sqlite Database file \.sqlite$ 29fde381a81ec8ee755961efca71a8ad75dc0a28802980c1da506fbf3626b241/layer.tar
|Found match var/lib/dnf/history.sqlite Database file \.sqlite$ d15f741566323f8b5861b59fab6e8f0cd4d224dc1b0e3a04e6dced2c262a906b/layer.tar
Dockerfile:
ARG MQ_URL
ARG BASE_IMAGE
ARG BASE_TAG
ARG GO_WORKDIR
LABEL summary=IBM MQ Advanced Server
LABEL description=Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises
LABEL vendor=IBM
LABEL maintainer=IBM
LABEL distribution-scope=private
LABEL authoritative-source-url=https://www.ibm.com/software/passportadvantage/
LABEL url=https://www.ibm.com/products/mq/advanced
LABEL io.openshift.tags=mq messaging
LABEL io.k8s.display-name=IBM MQ Advanced Server
LABEL io.k8s.description=Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises
LABEL base-image=registry.redhat.io/ubi8/ubi-minimal
LABEL base-image-release=8.5-204
COPY file:74de0b85048a852b4049a063d696f147cbb20ff373e4d947d0d7b365b87977ee in /usr/local/bin/
usr/
usr/local/
usr/local/bin/
usr/local/bin/install-mq.sh
COPY file:163d9dc38f595e70f8d9e5b9b12a76c51133311eab90edb48fc9c9dd840b641a in /usr/local/bin/
usr/
usr/local/
usr/local/bin/
usr/local/bin/install-mq-server-prereqs.sh
|4 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container MQ_URL=http://build:8080/9.2.4.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz RUN env \
&& mkdir /opt/mqm \
&& chmod u+x /usr/local/bin/install-*.sh \
&& sleep 1 \
&& install-mq-server-prereqs.sh \
&& install-mq.sh \
&& /opt/mqm/bin/security/amqpamcf \
&& chown -R 1001:root /opt/mqm/*
|4 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container MQ_URL=http://build:8080/9.2.4.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz RUN mkdir -p /run/runmqserver \
&& chown 1001:root /run/runmqserver
COPY file:084bc89afdba5aa4b789f85238b3ddd9e93b5e28a60990111280b0499dae3cae in /usr/local/bin/
usr/
usr/local/
usr/local/bin/
usr/local/bin/runmqserver
COPY multi:e47f2c08f045440ee7b3f1a5b24b43a4f4164918ba0042900a34db138b0b41f3 in /usr/local/bin/
usr/
usr/local/
usr/local/bin/
usr/local/bin/chkmqhealthy
usr/local/bin/chkmqready
usr/local/bin/chkmqstarted
COPY file:edebb47000f2e6c387d802053240b28ba8b263a96c852897f3567207bd0e5348 in /opt/mqm/licenses/notices-container.txt
opt/
opt/mqm/
opt/mqm/licenses/
opt/mqm/licenses/notices-container.txt
COPY file:fb55849aee5e85c2062d1d31628d48d652346709347886a51c2127bd36cb6ff1 in /etc/mqm/native-ha.ini.tpl
etc/
etc/mqm/
etc/mqm/native-ha.ini.tpl
COPY dir:b7af534eda9621b0de9e6052d2838260df23346b2d072b09d7fe687f4adb7c96 in /etc/mqm/web
etc/
etc/mqm/
etc/mqm/web/
etc/mqm/web/.wh..wh..opq
etc/mqm/web/installations/
etc/mqm/web/installations/Installation1/
etc/mqm/web/installations/Installation1/servers/
etc/mqm/web/installations/Installation1/servers/mqweb/
etc/mqm/web/installations/Installation1/servers/mqweb/mqwebuser.xml
etc/mqm/web/installations/Installation1/servers/mqweb/mqwebuser.xml.tpl
etc/mqm/web/installations/Installation1/servers/mqweb/tls.xml
etc/mqm/web/installations/Installation1/servers/mqweb/tls.xml.tpl
COPY file:4d5d9772edf00f4b508058ee08956d8f4e996f73fcc0c009aa001fd0810e627e in /etc/mqm/
etc/
etc/mqm/
etc/mqm/15-tls.mqsc.tpl
|4 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container MQ_URL=http://build:8080/9.2.4.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz RUN chmod ug+x /usr/local/bin/runmqserver \
&& chown 1001:root /usr/local/bin/*mq* \
&& chmod ug+x /usr/local/bin/chkmq* \
&& chown -R 1001:root /etc/mqm/* \
&& install --directory --mode 2775 --owner 1001 --group root /run/runmqserver \
&& touch /run/termination-log \
&& chown 1001:root /run/termination-log \
&& chmod 0660 /run/termination-log \
&& chmod -R g+w /etc/mqm/web
EXPOSE 1414 9157 9443
ENV MQ_OVERRIDE_DATA_PATH=/mnt/mqm/data MQ_OVERRIDE_INSTALLATION_NAME=Installation1 MQ_USER_NAME=mqm PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/mqm/bin
ENV MQ_GRACE_PERIOD=30
ENV LANG=en_US.UTF-8 AMQ_DIAGNOSTIC_MSG_SEVERITY=1 AMQ_ADDITIONAL_JSON_LOG=1 LOG_FORMAT=basic
USER 1001
ENV MQ_CONNAUTH_USE_HTP=false
ENTRYPOINT ["runmqserver"]
ARG BASE_IMAGE
ARG BASE_TAG
ARG GO_WORKDIR
ENV MQ_DEV=true
LABEL summary=IBM MQ Advanced for Developers Server
LABEL description=Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises
LABEL vendor=IBM
LABEL distribution-scope=private
LABEL authoritative-source-url=https://www.ibm.com/software/passportadvantage/
LABEL url=https://www.ibm.com/products/mq/advanced
LABEL io.openshift.tags=mq messaging
LABEL io.k8s.display-name=IBM MQ Advanced for Developers Server
LABEL io.k8s.description=Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises
LABEL base-image=registry.redhat.io/ubi8/ubi-minimal
LABEL base-image-release=8.5-204
USER 0
COPY file:d16dbd18619fbb2fda4454b3a94ae0bd32d88300e68130b826731921576d808c in /opt/mqm/lib64/
opt/
opt/mqm/
opt/mqm/lib64/
opt/mqm/lib64/mqhtpass.so
COPY file:14e173f3dfb278eb332a89d98493294d824250a738da1fd0a17a2f209728c0d2 in /etc/mqm/
etc/
etc/mqm/
etc/mqm/qm-service-component.ini
COPY file:f6cedf077e8dfc3e33aa7d8c0d1aecdd032041c158f93e902e2c5fee589df87b in /etc/mqm/
etc/
etc/mqm/
etc/mqm/mq.htpasswd
|3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container RUN chmod 0660 /etc/mqm/mq.htpasswd
COPY file:749c034e86ef1090396f610d89cf8a357a4f6fe22096514854dce65f402e415e in /usr/local/bin/
usr/
usr/local/
usr/local/bin/
usr/local/bin/install-extra-packages.sh
|3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container RUN chmod u+x /usr/local/bin/install-extra-packages.sh \
&& sleep 1 \
&& install-extra-packages.sh
|3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container RUN mkdir -p /run/runmqdevserver \
&& chown 1001:root /run/runmqdevserver
COPY file:01dd6f8df223f9efd765efa60edec77dea3ad97293128d5d76dedadf419f143a in /usr/local/bin/
usr/
usr/local/
usr/local/bin/
usr/local/bin/runmqdevserver
COPY multi:dddbd8622bcb09004052dc47ba5e49f10f6cf2eaf183e7d2bce26797406f9872 in /etc/mqm/
etc/
etc/mqm/
etc/mqm/10-dev.mqsc.tpl
etc/mqm/20-dev-tls.mqsc.tpl
etc/mqm/admin.json.tpl
COPY dir:314872ec79916fd02399a577dc0a459320cae06046396e93b0377e20de3c341f in /etc/mqm/web
etc/
etc/mqm/
etc/mqm/web/
etc/mqm/web/installations/
etc/mqm/web/installations/Installation1/
etc/mqm/web/installations/Installation1/servers/
etc/mqm/web/installations/Installation1/servers/mqweb/
etc/mqm/web/installations/Installation1/servers/mqweb/mqwebuser.xml
|3 BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal BASE_TAG=8.5-204 GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container RUN chown -R 1001:root /etc/mqm/* \
&& chmod -R g+w /etc/mqm/web \
&& chmod +x /usr/local/bin/runmq* \
&& install --directory --mode 2775 --owner 1001 --group root /run/runmqdevserver
ENV MQ_ENABLE_EMBEDDED_WEB_SERVER=1 MQ_GENERATE_CERTIFICATE_HOSTNAME=localhost
ENV LD_LIBRARY_PATH=/opt/mqm/lib64
ENV MQ_CONNAUTH_USE_HTP=true
ENV MQS_PERMIT_UNKNOWN_ID=true
USER 1001
ENTRYPOINT ["runmqdevserver"]
LABEL architecture=amd64
LABEL build-date=2021-11-12T16:23:29+0000
LABEL name=ibm-mqadvanced-server-dev
LABEL release=r1
LABEL run=docker run -d -e LICENSE=accept ibm-mqadvanced-server-dev:9.2.4.0-r1.20211112161954.1f6d37a-amd64
LABEL vcs-ref=1f6d37afedb079b354e2a39461332c37a6e41bb7
LABEL vcs-type=git
LABEL vcs-url=git@github.ibm.com:mq-cloudpak/mq-container
LABEL version=9.2.4.0