docker---通过images的镜像反推出Dockerfile

没有命令直接 通过image镜像 就能反编译 获得 Dockerfile。

但是 我们可以根据 docker history命令 进行反推。

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 images 找到镜像id和tag

zhangxiaofans-MacBook-Pro:Downloads joe$ docker images
REPOSITORY                                                       TAG                 IMAGE ID            CREATED             SIZE
debian                                                           stretch             6b14557ccda6        2 months ago        101MB

使用history命令

zhangxiaofans-MacBook-Pro:Downloads joe$ docker history  debian:stretch
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
6b14557ccda6        2 months ago        /bin/sh -c #(nop)  CMD ["bash"]                 0B                  
<missing>           2 months ago        /bin/sh -c #(nop) ADD file:08c5ab7c53526da15…   101MB               
zhangxiaofans-MacBook-Pro:Downloads joe$ 

如果要让CREATED BY 列完整显示,可以加上–no-trunc参数。

自定义输出格式:–format

docker history  debian:stretch --format "table {{.ID}}\t{{.CreatedBy}}" --no-trunc

输出如下:

zhangxiaofans-MacBook-Pro:Downloads joe$ docker history  debian:stretch --format "table {{.ID}}\t{{.CreatedBy}}" --no-trunc
IMAGE                                                                     CREATED BY
sha256:6b14557ccda6d43137ebcf46490778af1c8bae98e26b49e1f5ca216bcb9ebf20   /bin/sh -c #(nop)  CMD ["bash"]
<missing>                                                                 /bin/sh -c #(nop) ADD file:08c5ab7c53526da155d6be40a9795fc08afc9f47bd333c096e90185fe9fab2b1 in / 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

张小凡vip

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

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

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

打赏作者

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

抵扣说明:

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

余额充值