Fork me on GitHub

Docker之镜像安全

安全一直是一个不出事没人关心等到出事的时候也已经晚了的话题。最近研究了下Docker镜像安全的内容,以测试的Anchore和Clair两个项目的简单介绍。这类工具的共同特点就是静态分析镜像里的内容,找出其中的软件包和对应的版本,然后和从各大Linux版本的CVE源下载漏洞数据库做匹配,最终判断镜像里的安全漏洞。

Anchore

项目地址
新项目地址

1
2
3
4
5
6
7
# yum install -y epel-release
# yum install -y python-pip rpm-python dpkg
# pip install anchore
# anchore feeds sync
# docker pull nginx
# anchore analyze --image nginx:latest --imagetype base # 分析本地数据
# anchore gate --image nginx:latest # 从分析结果生成报告

报告中会显示哪个包有漏洞,已经漏洞对应的链接。

Clair

项目地址
Docker方式

1
2
3
4
5
6
7
8
# mkdir $PWD/clair_config
# curl -L https://raw.githubusercontent.com/coreos/clair/master/config.yaml.sample -o $PWD/clair_config/config.yaml
# docker run -d -e POSTGRES_PASSWORD="" -p 5432:5432 postgres:9.6
# docker run --net=host -d -p 6060-6061:6060-6061 -v $PWD/clair_config:/config quay.io/coreos/clair-git:latest -config=/config/config.yaml
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
836e3e93c84d quay.io/coreos/clair-git:latest "/usr/bin/dumb-ini..." 4 seconds ago Up 3 seconds keen_johnson
cf0593d761ff postgres:9.6 "docker-entrypoint..." 15 minutes ago Up 15 minutes 0.0.0.0:5432->5432/tcp nostalgic_hamilton

Clair只是提供了api接口,所以使用起来并不是那么方便,在Github上找clairctl这个客户端工具,可以方便的测试Clair的功能.
clairctl项目GitHub地址

1
# curl -L https://raw.githubusercontent.com/jgsqware/clairctl/master/install.sh | sh

参考资料

docker基础教程之镜像安全

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/e3e64f51.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!