# history 镜像各层构建时候执行命令查看 docker history gcc # IMAGE CREATED CREATED BY SIZE # 21f378ba43ec 4 days ago /bin/sh -c set -ex; dpkg-divert --divert /u… 12.7kB # <missing> 4 days ago /bin/sh -c set -ex; echo '/usr/local/lib64'… 53.8kB # <missing> 4 days ago /bin/sh -c set -ex; savedAptMark="$(apt-ma… 382MB # <missing> 4 days ago /bin/sh -c #(nop) ENV GCC_VERSION=10.2.0 0B # <missing> 5 days ago /bin/sh -c #(nop) ENV GCC_MIRRORS=https://f… 0B # <missing> 5 days ago /bin/sh -c set -ex; for key in $GPG_KEYS; d… 29.5kB # <missing> 5 days ago /bin/sh -c #(nop) ENV GPG_KEYS=B215C1633BCA… 0B # <missing> 5 days ago /bin/sh -c set -ex; if ! command -v gpg > /… 0B # <missing> 5 days ago /bin/sh -c set -ex; apt-get update; DEBIAN… 510MB # <missing> 5 days ago /bin/sh -c apt-get update && apt-get install… 146MB # <missing> 5 days ago /bin/sh -c set -ex; if ! command -v gpg > /… 17.5MB # <missing> 5 days ago /bin/sh -c apt-get update && apt-get install… 16.5MB # <missing> 6 days ago /bin/sh -c #(nop) CMD ["bash"] 0B # <missing> 6 days ago /bin/sh -c #(nop) ADD file:89dfd7d3ed77fd5e0… 114MB
#rpm安装方式 #Ubuntu/Debian wget https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb sudo apt install ./dive_0.9.2_linux_amd64.deb #RHEL/Centos curl -OL https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.rpm rpm -i dive_0.9.2_linux_amd64.rpm #Arch Linux #Available as dive in the Arch User Repository (AUR). yay -S dive # mac brew install dive
# 按键绑定 Ctrl + C Exit Tab Switch between the layer and filetree views Ctrl + F Filter files PageUp Scroll up a page PageDown Scroll down a page Ctrl + A Layer view: see aggregated image modifications
Ctrl + L Layer view: see current layer modifications Space Filetree view: collapse/uncollapse a directory Ctrl + Space Filetree view: collapse/uncollapse all directories Ctrl + A Filetree view: show/hide added files Ctrl + R Filetree view: show/hide removed files Ctrl + M Filetree view: show/hide modified files Ctrl + U Filetree view: show/hide unmodified files Ctrl + B Filetree view: show/hide file attributes PageUp Filetree view: scroll up a page PageDown Filetree view: scroll down a page
# 1.简单分析实例 $docker images # REPOSITORY TAG IMAGE ID CREATED SIZE # go-hello latest d1bb1eb974f4 19 hours ago 812MB $docker run --rm -it \ -v /var/run/docker.sock:/var/run/docker.sock \ wagoodman/dive:latest go-hello:latest # Image Source: docker://go-hello:latest # Fetching image... (this can take a while for large images) # Analyzing image... # Building cache...
rules: # If the efficiency is measured below X%, mark as failed. # Expressed as a ratio between 0-1. lowestEfficiency: 0.95
# If the amount of wasted space is at least X or larger than X, mark as failed. # Expressed in B, KB, MB, and GB. highestWastedBytes: 20MB
# If the amount of wasted space makes up for X% or more of the image, mark as failed. # Note: the base image layer is NOT included in the total image size. # Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
2.Skopeo - 镜像同步工具
描述: 我们从以下的两个利用场景中可以看见看见此工具妙用;
应用场景1.如何在机器上pull拉取Registry A Harbor中的镜像,然后构造完成后重新打上Tag然后再Push到另外一个 registry B Harbor 上去,相当于一个同步镜像操作,但和 harbor 里在带的那个镜像同步还有很大的不同,我们仅仅需要同步特定 tag 的镜像,而不是整个 harbor 或者 project 里的全部镜像;目前我们的做法还是最简单的方式,使用 docker 命令行的方式来 pull 镜像,然后打 tag 接着 push 到 B harbor。但是啊,当同步二三百个的镜像,或者镜像的总大小几十 GB 的时候这种原始的方法速度还是太慢了,于是就思考有没有另一个工具可以直接将 registry A 中的某个镜像同步到 registry B 中去。简单的说使用 skopeo copy 两个 registry 中的镜像时,skopeo 请求两个 registry API 直接 copy original blob 到另一个 registry ,这样免去了像docker pull –> docker tag –> docker push 那样 pull 镜像对镜像进行解压缩,push 镜像进行压缩。尤其是在搬运一些较大的镜像(几GB 或者几十 GB的镜像,比如 nvidia/cuda ),使用 skopeo copy 的加速效果十分明显。
Available Commands: # 复制一个镜像从 A 到 B,这里的 A 和 B 可以为本地 docker 镜像或者 registry 上的镜像。 copy Copy an IMAGE-NAME from one location to another
# 删除一个镜像,可以是本地 docker 镜像或者 registry 上的镜像 delete Delete image IMAGE-NAME help Help about any command
# 查看一个镜像的 manifest 火车 image config 详细信息 inspect Inspect image IMAGE-NAME # 列出一个 registry 上某个镜像的所有 tag,在某些脚本中可以进行使用; list-tags List tags in the transport/repository specified by the
# 登录到某个 registry,和 docker login 类似 login Login to a container registry # 退出已经登录到某个 registry 的 auth 信息,和 docker logout 类似 logout Logout of a container registry
# 同步一个镜像从 A 到 B,感觉和 copy 一样,但 sync 支持的参数更多,功能更强大。在 0.14.0 版本的时候是没有 sync 选项的,到了 0.14.2 才有,现在是 1.0.0 sync Synchronize one or more images from one location to another manifest-digest Compute a manifest digest of a file # 计算文件的清单摘要 standalone-sign Create a signature using local files # 使用本地文件创建签名 standalone-verify Verify a signature using local files # 验证本地文件的签名
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!