docker history 查看docker镜像构建过程 还原dockerfile 查看启动参数

介绍:

~]# docker history --help
Usage:  docker history [OPTIONS] IMAGE
Show the history of an image
Options:
      --format string   Pretty-print images using a Go template
      --help            Print usage
  -H, --human           Print sizes and dates in human readable format (default true)
      --no-trunc        Don't truncate output
  -q, --quiet           Only show numeric IDs

示例:

~]# docker history kubeguide/tomcat-app:v1
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
a29e200a18e9        2 years ago         /bin/sh -c #(nop) ADD dir:c5c3bddef49cbc9f...   992kB               
<missing>           2 years ago         /bin/sh -c #(nop) MAINTAINER bestme <bestm...   0B                  
<missing>           2 years ago         /bin/sh -c #(nop) CMD ["catalina.sh" "run"]     0B                  
<missing>           2 years ago         /bin/sh -c #(nop) EXPOSE 8080/tcp               0B                  
<missing>           2 years ago         /bin/sh -c set -e  && nativeLines="$(catal...   0B                  
<missing>           2 years ago         /bin/sh -c set -x   && curl -fSL "$TOMCAT_...   16.6MB              
<missing>           2 years ago         /bin/sh -c #(nop) ENV TOMCAT_TGZ_URL=https...   0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ENV TOMCAT_VERSION=8.0.35     0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ENV TOMCAT_MAJOR=8            0B                  
<missing>           2 years ago         /bin/sh -c set -ex  && for key in   05AB33...   114kB               
<missing>           2 years ago         /bin/sh -c apt-get update && apt-get insta...   7.18MB              
<missing>           2 years ago         /bin/sh -c {   echo 'deb http://httpredir....   172B                
<missing>           2 years ago         /bin/sh -c #(nop) ENV OPENSSL_VERSION=1.0....   0B                  
<missing>           2 years ago         /bin/sh -c #(nop) WORKDIR /usr/local/tomcat     0B                  
<missing>           2 years ago         /bin/sh -c mkdir -p "$CATALINA_HOME"            0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ENV PATH=/usr/local/tomc...   0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ENV CATALINA_HOME=/usr/l...   0B                  
<missing>           2 years ago         /bin/sh -c set -x  && apt-get update  && a...   163MB               
<missing>           2 years ago         /bin/sh -c #(nop) ENV JAVA_DEBIAN_VERSION=...   0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ENV JAVA_VERSION=7u101        0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ENV JAVA_HOME=/usr/lib/j...   0B                  
<missing>           2 years ago         /bin/sh -c {   echo '#!/bin/sh';   echo 's...   87B                 
<missing>           2 years ago         /bin/sh -c #(nop) ENV LANG=C.UTF-8              0B                  
<missing>           2 years ago         /bin/sh -c apt-get update && apt-get insta...   1.17MB              
<missing>           2 years ago         /bin/sh -c apt-get update && apt-get insta...   44.3MB              
<missing>           2 years ago         /bin/sh -c #(nop) CMD ["/bin/bash"]             0B                  
<missing>           2 years ago         /bin/sh -c #(nop) ADD file:5d8521419ad6cfb...   125MB

如果要让CREATED BY 列完整显示,可以加上 --no-trunc 参数。直接在shell中看会比较乱,可以输出到文件查看,就比较直观了

以phpmyadmin docker镜像为例,效果如下:

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用以下步骤查看docker镜像Dockerfile文件详细: 1. 首先使用docker image ls命令,查看已有的docker镜像列表。 2. 找到目标镜像的ID或名称。 3. 使用docker history命令,查看镜像的历史命令记录。 4. 找到该镜像的最后一条命令记录,并复制其对应的命令ID。 5. 使用docker inspect命令,查看该命令ID对应的详细信息。 6. 在查看的信息中,找到Config项,其中包含了该镜像Dockerfile信息。 例如,假设我们要查看名为ubuntu的镜像Dockerfile信息,可以按照以下步骤进行操作: 1. 运行docker image ls命令,查看已有的docker镜像列表: ``` $ docker image ls ``` 2. 找到目标镜像的ID或名称: ``` REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 74435f89ab78 9 days ago 73.9MB ``` 3. 使用docker history命令,查看镜像的历史命令记录: ``` $ docker history ubuntu ``` 4. 找到该镜像的最后一条命令记录,并复制其对应的命令ID: ``` IMAGE CREATED CREATED BY SIZE COMMENT 74435f89ab78 9 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B ``` 5. 使用docker inspect命令,查看该命令ID对应的详细信息: ``` $ docker inspect 74435f89ab78 ``` 6. 在查看的信息中,找到Config项,其中包含了该镜像Dockerfile信息: ``` "Config": { "Hostname": "", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": null, "Cmd": [ "/bin/bash" ], "Image": "sha256:74435f89ab784a13c2fa4b55d5cc4a3aa5cb8c4d2c7b2a0d7aaf84b17d8b4c9b", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值