我正在尝试设置clairctl来扫描我们的应用程序映像,因此我想安装完整的clairctl、clair扫描器和post逗号数据库。我做了以下步骤:
)通过运行“curl -L https:// -L_sh”下载了clairctl的二进制版本。
( ii)执行命令“git克隆git@github.com:jgsqware/clairctl.git $GOPATH/src/github.com/jgsqware/clairctl”,但错误消息失败。
[root@clair-server ~]# git clone git@github.com:jgsqware/clairctl.git $GOPATH/src/github.com/jgsqware/clairctl
Cloning into '/src/github.com/jgsqware/clairctl'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
[root@clair-server ~]#为了解决这个问题,下面的方法也是如此。如果这是一个可能影响很多人的通用问题,那么您可能希望用解决方法更新项目的README.md,以便帮助clairctl的其他用户。
git clone git clone https:// github.com/jgsqware/clairctl.git
export GOPATH=$PATH:~/go
mkdir -p $GOPATH/src/github.com/jgsqware/clairctl
mv clairctl $GOPATH/src/github.com/jgsqware/然后执行以下通过的命令:
cd $GOPATH/src/github.com/jgsqware/clairctl
docker-compose up -d postgres4)然后执行命令“docker-compose clairctl clairctl health”,该命令失败了。我在谷歌上搜索了这个错误,检查了文件docker-come.yml。在此基础上,我执行了“码头-合成-d clairctl”,这是没有提到的。这是下载并启动clair和clairctl图像的时候。然后我做了一个成功的“码头-这是成功的。您可能需要在文档中添加缺少的命令:“docker-compose -d postgres”,以便帮助clairctl的其他用户。
[root@clair-server clairctl]# docker-compose exec clairctl clairctl health
Clair: ✔
[root@clair-server clairctl]# clairctl health --log-level debug
2018-09-19 09:45:27.038127 D | config: No config file used
2018-09-19 09:45:27.038608 D | clair: requesting health on: http:// localhost:6061/health
2018-09-19 09:45:27.040779 E | clair: requesting Clair health: Get http:// localhost:6061/health: dial tcp [::1]:6061: getsockopt: connection refused
Clair: ✘
[root@clair-server clairctl]#[root@clair-server clairctl]# docker login -u username -p the-password
[root@clair-server clairctl]# docker-compose exec clairctl clairctl analyze my-org/my-container:186 --log-level debug
2018-09-19 13:49:10.858615 D | config: Using config file: /home/clairctl/clairctl.yml
2018-09-19 13:49:10.859175 D | dockerdist: Downloading manifest for my-org/my-container:186
2018-09-19 13:49:10.859395 D | dockerdist: Retrieving repository client
2018-09-19 13:49:11.240796 D | dockerdist: endpoint.TLSConfig.InsecureSkipVerify: true
client quit unexpectedly
2018-09-19 13:49:15.415043 C | cmd: retrieving manifest for "my-org/my-container:186": errors:
denied: requested access to the resource is denied
unauthorized: authentication required
[root@clair-server clairctl]#
[root@clair-server clairctl]#clairctl analyze my-org/my-container:186 --log-level debug
2018-09-19 09:51:33.513208 D | config: No config file used
2018-09-19 09:51:33.513675 D | dockerdist: Downloading manifest for my-org/my-container:186
2018-09-19 09:51:33.514031 D | dockerdist: Retrieving repository client
2018-09-19 09:51:37.131535 D | dockerdist: endpoint.TLSConfig.InsecureSkipVerify: true
2018-09-19 09:51:41.656177 D | dockerdist: manifest type: *schema2.DeserializedManifest
2018-09-19 09:51:41.656235 D | dockerdist: retrieved schema2 manifest, no verification
2018-09-19 09:51:41.656286 I | config: retrieving interface for local IP
2018-09-19 09:51:41.656301 D | config: no interface provided, looking for docker0
2018-09-19 09:51:41.656830 I | clair: Pushing Layer 1/7 [sha256:605ce]
2018-09-19 09:51:41.656982 D | clair: Saving sha256:605ce1bd3f3164f2949a30501cc596f52a72de05da1306ab360055f0d7130c32[https:// registry-1.docker.io/v2]
2018-09-19 09:51:41.657113 D | clair: auth.insecureSkipVerify: true
2018-09-19 09:51:41.657150 D | clair: request.URL.String(): https:// registry-1.docker.io/v2/my-org/my-container/blobs/sha256:605ce1bd3f3164f2949a30501cc596f52a72de05da1306ab360055f0d7130c32
2018-09-19 09:51:42.809395 I | clair: pull from clair is unauthorized
2018-09-19 09:51:43.941475 I | clair: adding layer 1/7 [sha256:605ce]: pushing layer to clair: Post http:// localhost:6060/v1/layers: dial tcp [::1]:6060: getsockopt: connection refused
client quit unexpectedly
2018-09-19 09:51:43.941545 C | cmd: pushing image "my-org/my-container:186": pushing layer to clair: Post http:// localhost:6060/v1/layers: dial tcp [::1]:6060: getsockopt: connection refused
[root@clair-server clairctl]#我希望最终使用CLI将clairctl与Jenkins集成,以实现质量/安全门。有没有什么方法可以让扫描继续进行(理想的情况下没有对接-合成)工作?你能帮帮我吗?我试着在谷歌上搜索并阅读关于如何克服这一障碍的文章,但却想不出办法。我想把这个问题在clairctl/Lobby上贴在Gitter上,但我觉得我不能详细表达自己的意思。
任何指导、帮助都将不胜感激。你能帮帮我吗?
发布于 2018-09-25 05:17:53
我最终发现Clair服务器在容器中运行,它的服务端口- 6060 (API)和6061 (Health)仅在容器上下文中可用。我通过运行以下命令确认了这一点:
命令查看clair容器中打开的端口。
docker-compose exec clair netstat -anp
命令查看clairctl容器中打开的端口。
docker-compose exec clairctl netstat -anp
clairctl分析操作在容器中失败,因为docker登录上下文在容器中不可用。我想,我必须从容器上下文之外的Clair服务器内部公开端口6060,6061。只有到那时,才能使用clairctl二进制文件将其复制到容器外,在容器中可以使用docker登录上下文。我做了以下三个更改文章,可以成功地运行clairctl命令。
uri参数的值从uri: http://clair更新为uri: http://localhostclair部分中的ports子句,如下所示:映像: quay.io/coreos/ clair: v2.0.0重新启动:除非-已停止端口:- "6060:6060“- "6061:6061”这将clair容器中的端口6060,6061暴露给本地主机,之后,像clairctl health和clairctl analyze 这样的命令就成功地工作了。
https://devops.stackexchange.com/questions/5018
复制相似问题