您现在的位置是:首页 > 文章详情

jenkins slave连接harbor认证的坑儿

日期:2018-05-29点击:418

昨天遇到的问题。

公司是docker运行jenkins master。

然后然后JNLP来操作jenkins slave。

jenkins slave也是docker方式运行。

slave里面跑的docker都是以docker out docker的方式映射到宿主slave的docker命令。


jenkins 2.7,新版本安装了pipeline插件。

并用yet another docker插件来制作docker镜像。

在docker push时,先需要harbor仓库认证。

写法如下:


withDockerRegistry(registry: [credentialsId: 'harbor_admin', url: 'http://harbor.paic.com.cn']) { // some block }



这样的写法,生成的是.dockercfg认证这件,

然后,死活推不到harbor上去。

(将login生成的认证文件也挂到了slave的宿主机上)


找了N多网页,试了N多方面,都不行。

最好,只有自己在pipeline里写docker login 命令,才能生成正确的.docker/config.json文件。

然后,将这个config.json文件挂载到jenkins slave主机上正确的位置,就OK了。(因为docker out docker,,所以认证一定是宿主机的docker认证和操作命令)


/usr/local/docker/docker:/usr/bin/docker /run/docker.sock:/run/docker.sock /docker/jenkins_home/.m2/:/root/.m2/ /docker/home/docker/.docker:/home/jenkins/.docker



原来

Registry 1.0 - Docker pre 1.6:认证文件为.dockercfg

Registry 2.0 - Docker 1.6 and up:认证文件为.docker/config.json

http://mesosphere.github.io/marathon/docs/native-docker-private-registry.html



Use a Private Docker Registry with the Docker Containerizer

Registry 1.0 - Docker pre 1.6

To supply credentials to pull from a private registry, add a .dockercfg to the uris field of your app. The $HOMEenvironment variable will then be set to the same value as $MESOS_SANDBOX so Docker can automatically pick up the config file.

Registry 2.0 - Docker 1.6 and up

To supply credentials to pull from a private registry, add a docker.tar.gz file to the uris field of your app. The docker.tar.gz file should include the .docker directory and the contained .docker/config.json

原文链接:https://yq.aliyun.com/articles/598216
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章