用于检查容器/图像/dockerfile的通用规则/最佳实践的工具。
colin的Python项目详细描述
科林
用于检查容器图像和dockerfile的通用规则和最佳实践的工具。
有关详细信息,请查看我们的documentation on colin.readthedocs.io。
功能
- 根据规则集验证选定的项目。
- 工件可以是容器图像和dockerfile。
- 我们提供了一个默认的规则集,我们相信每个容器映像都应该满足。
- 有一个规则集来验证工件是否符合Fedora Container Guidelines
- colin可以在规则集中列出可用的规则集和列表检查。
- 有一个可用的python api
- colin可以很容易地集成到您的工作流中,它可以提供json格式的结果。
安装
通过pip
如果您使用的是Fedora发行版,请安装python3 pyxattr,这样您就不会 当从pypi获得它时,必须自己编译它。
$ pip3 install --user colin
colin
仅在python 3.6+上受支持。
关于Fedora分布
科林被打包在官方的Fedora存储库中:
$ dnf install -y colin
要求
要检查
image
目标类型,必须安装podman。如果需要检查本地Docker图像,则需要在图像前面加上docker-daemon
(例如colin check docker-daemon:docker.io/openshift/origin-web-console:v3.11
)。如果要使用
ostree
目标,需要安装以下工具:
用法
$ colin --help
Usage: colin [OPTIONS] COMMAND [ARGS]...
COLIN -- Container Linter
Options:
-V, --version Show the version and exit.
-h, --help Show this message and exit.
Commands:
check Check the image/dockerfile (default).
info Show info about colin and its dependencies.
list-checks Print the checks.
list-rulesets List available rulesets.
$ colin check --help
Usage: colin check [OPTIONS] TARGET
Check the image/dockerfile (default).
Options:
-r, --ruleset TEXT Select a predefined ruleset (e.g. fedora).
-f, --ruleset-file FILENAME Path to a file to use for validation (by
default they are placed in
/usr/share/colin/rulesets).
--debug Enable debugging mode (debugging logs, full
tracebacks).
--json FILENAME File to save the output as json to.
--stat Print statistics instead of full results.
-s, --skip TEXT Name of the check to skip. (this option is
repeatable)
-t, --tag TEXT Filter checks with the tag.
-v, --verbose Verbose mode.
--checks-path DIRECTORY Path to directory containing checks (default
['/home/flachman/.local/lib/python3.7/site-
packages/colin/checks']).
--pull Pull the image from registry.
--target-type TEXT Type of selected target (one of image,
dockerfile, ostree). For ostree, please specify
image name and path like this: image@path
--timeout INTEGER Timeout for each check in seconds.
(default=600)
--insecure Pull from an insecure registry (HTTP or invalid
TLS).
-h, --help Show this message and exit.
让我们试一试:
$ colin -f ./rulesets/fedora.json registry.fedoraproject.org/f29/cockpit
PASS:Label 'architecture' has to be specified.
PASS:Label 'build-date' has to be specified.
FAIL:Label 'description' has to be specified.
PASS:Label 'distribution-scope' has to be specified.
:
:
PASS:10 FAIL:8
直接从git
可以直接从git使用colin:
$ git clone https://github.com/user-cont/colin.git
$ cd colin
我们现在可以运行分析:
$ python3 -m colin.cli.colin -f ./rulesets/fedora.json registry.fedoraproject.org/f29/cockpit
PASS:Label 'architecture' has to be specified.
PASS:Label 'build-date' has to be specified.
FAIL:Label 'description' has to be specified.
PASS:Label 'distribution-scope' has to be specified.
:
:
PASS:10 FAIL:8
< H3>退出代码< EH3>柯林可以用多个代码退出:
0
-->;确定1
-->;执行中出错2
-->;cli错误,错误参数3
-->;至少有一个检查失败