docker命令:拉取完docker镜像后,如何查看该镜像的dockerfile文件内容

命令:

docker history 镜像id

[root@localhost docker-files]# ls
apisix1_dockerfile  centos_dockerfile  entrypoint.sh
[root@localhost docker-files]# cat centos_dockerfile 
FROM centos:7
MAINTAINER yangyue<= <yangyue@yangyue.cn>

RUN yum install -y vim
WORKDIR /usr

cmd /bin/bash
[root@localhost docker-files]# docker images
REPOSITORY                                               TAG                 IMAGE ID            CREATED             SIZE
[root@localhost docker-files]# docker build -f ./centos_dockerfile  -t centostest1:1 .
Sending build context to Docker daemon 4.608 kB
Step 1/5 : FROM centos:7
 ---> eeb6ee3f44bd
Step 2/5 : MAINTAINER yangyue<= <yangyue@yangyue.cn>
 ---> Using cache
 ---> 66086d8a9f63
Step 3/5 : RUN yum install -y vim
 ---> Using cache
 ---> b7a971570078
Step 4/5 : WORKDIR /usr
 ---> Using cache
 ---> 1d844be7b22e
Step 5/5 : CMD /bin/bash
 ---> Using cache
 ---> 19f1820de286
Successfully built 19f1820de286
[root@localhost docker-files]# docker images
REPOSITORY                                               TAG                 IMAGE ID            CREATED             SIZE
centostest1                                              1                   19f1820de286        21 hours ago        408 MB
[root@localhost docker-files]# docker history 19f1820de286
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
19f1820de286        21 hours ago        /bin/sh -c #(nop)  CMD ["/bin/sh" "-c" "/b...   0 B                 
1d844be7b22e        21 hours ago        /bin/sh -c #(nop) WORKDIR /usr                  0 B                 
b7a971570078        21 hours ago        /bin/sh -c yum install -y vim                   204 MB              
66086d8a9f63        21 hours ago        /bin/sh -c #(nop)  MAINTAINER yangyue<= <y...   0 B                 
eeb6ee3f44bd        3 months ago        /bin/sh -c #(nop)  CMD ["/bin/bash"]            0 B                 
<missing>           3 months ago        /bin/sh -c #(nop)  LABEL org.label-schema....   0 B                 
<missing>           3 months ago        /bin/sh -c #(nop) ADD file:b3ebbe8bd304723...   204 MB              
[root@localhost docker-files]# 

查看详细信息:
docker history --format {{.CreatedBy}} --no-trunc=true 镜像id |sed "s/\/bin\/sh\ -c\ \#(nop)\ //g"|sed "s/\/bin\/sh\ -c/RUN/g" | tac

root@bjali-ecs-172-16-192-65:/home/op# docker imagesREPOSITORY                TAG             IMAGE ID       CREATED         SIZE
<none>                    <none>          fb12486a9093   21 hours ago    
apache/apisix             2.10.0-alpine   627d00c649fc   2 months ago    110MB
root@XX:/home/op# docker history --format {{.CreatedBy}} --no-trunc=true 627d00c649fc|sed "s/\/bin\/sh\ -c\ \#(nop)\ //g"|sed "s/\/bin\/sh\ -c/RUN/g" | tac
ADD file:ecdfb91a737d6c292265c1b77ffd3d82ba810dd43ea4ef79714b66b1da74a5aa in /
 CMD ["/bin/sh"]
ARG ENABLE_PROXY
RUN |1 ENABLE_PROXY=false RUN set -x     && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories)     && apk add --no-cache bash libstdc++ curl tzdata # buildkit
WORKDIR /usr/local/apisix
COPY /usr/local/openresty/ /usr/local/openresty/ # buildkit
COPY /usr/local/apisix/ /usr/local/apisix/ # buildkit
COPY /usr/bin/apisix /usr/bin/apisix # buildkit
RUN |1 ENABLE_PROXY=false RUN ln -sf /dev/stdout /usr/local/apisix/logs/access.log     && ln -sf /dev/stderr /usr/local/apisix/logs/error.log # buildkit
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
EXPOSE map[9080/tcp:{} 9443/tcp:{}]
CMD ["sh" "-c" "/usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
STOPSIGNAL SIGQUIT
root@XX:/home/op# ls
  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

?abc!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值