container-diff 是 Google 开源的一个分析和比较容器镜像的工具,可用来分析 Docker 镜像之间的差异。
container-diff 可通过几个不同的标准(角度)来检查镜像,包括:
Docker 镜像历史
镜像文件系统
Apt 包管理器
pip 包管理器
npm 包管理器
macOS
curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-darwin-amd64 && chmod +x container-diff-darwin-amd64 && sudo mv container-diff-darwin-amd64 /usr/local/bin/container-diff
Linux
curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && chmod +x container-diff-linux-amd64 && sudo mv container-diff-linux-amd64 /usr/local/bin/container-diff
不想使用 sudo 的话还可以这样
curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && chmod +x container-diff-linux-amd64 && mkdir $HOME/bin && export PATH=$PATH:$HOME/bin && mv container-diff-linux-amd64 $HOME/bin/container-diff
Windows
下载 container-diff-windows- amd64.exe 文件,重命名为 container-diff.exe 并将其添加到路径。
container-diff.exe
单个分析:
container-diff analyze <img> [Run default analyzers] container-diff analyze <img> --type=history [History] container-diff analyze <img> --type=file [File System] container-diff analyze <img> --type=pip [Pip] container-diff analyze <img> --type=apt [Apt] container-diff analyze <img> --type=node [Node] container-diff analyze <img> --type=apt --type=node [Apt and Node] # --type=<analyzer1> --type=<analyzer2> --type=<analyzer3>,...
多个对比:
container-diff diff <img1> <img2> [Run default differs] container-diff diff <img1> <img2> --type=history [History] container-diff diff <img1> <img2> --type=file [File System] container-diff diff <img1> <img2> --type=pip [Pip] container-diff diff <img1> <img2> --type=apt [Apt] container-diff diff <img1> <img2> --type=node [Node]