dive 是一个方便的观察容器各层信息的工具,同时也集成了容器构建命令,方便我们在构建容器
镜像的同时查询镜像各层的变动信息
安装
mac 系统,可以按照自己的系统选择安装方式
wget https://github.com/wagoodman/dive/releases/download/v0.6.0/dive_0.6.0_darwin_amd64.tar.gz
解压,并配置系统环境变量
使用
- 包含的命令
dive --help
This tool provides a way to discover and explore the contents of a docker image. Additionally the tool estimates
the amount of wasted space and identifies the offending files from the image.
Usage:
dive [IMAGE] [flags]
dive [command]
Available Commands:
build Builds and analyzes a docker image from a Dockerfile (this is a thin wrapper for the `docker build` command).
help Help about any command
version print the version number and exit (also --version)
Flags:
--ci-config string If CI=true in the environment, use the given yaml to drive validation rules. (default ".dive-ci")
--config string config file (default is $HOME/.dive.yaml, ~/.config/dive.yaml, or $XDG_CONFIG_HOME/dive.yaml)
-h, --help help for dive
-j, --json string Skip the interactive TUI and write the layer analysis statistics to a given file.
-v, --version display version number
Use "dive [command] --help" for more information about a command.
- 查看nginx 构建信息
dive nginx
- 效果
说明
我们可以同时在构建的时候使用dive 帮忙我们查看每层镜像的变动信息,方便进行容器镜像的优化调整,使用dive build -t <imagetag> .
命令
同时我们也可以使用docker in docker 的模式做为ci/cd 的一部分,方便进行监控容器信息
参考资料
https://github.com/wagoodman/dive