Docker连接General Version Control System(Gitlab/Github)自动build

由于官方只支持Docker连接Github的自动build,那么我们使用其他version control(如Gitlab,CVS等)的同学们应该怎么做呢。

 

博主使用的方案是jenkins+jenkins提供的docker插件。

需要用到DooD (Docker-outside-of-Docker) 或者DinD(Docker-in-Docker)技术。

 

具体参照:

http://container-solutions.com/running-docker-in-jenkins-in-docker/

在jenkins容器可以访问docker命令完成以后,继续安装相关jenkins上的docker插件来完成gitlab上docker的自动build过程。

本文中使用的docker相关插件包括以下五个(参考文章http://www.linuxidc.com/Linux/2015-07/120287.htm):

  • CloudBees Docker Build and Publish plugin — This plugin provides the ability to build projects with a Dockerfile, and publish the resultant tagged image (repo) to the docker registry.
  • Docker build step plugin — This plugin allows to add various Docker commands into you job as a build step.
  • Docker Plugin — This plugin allows slaves to be dynamically provisioned using Docker.
  • Kubernetes Plugin — This plugin allows slaves to be dynamically provisioned on multiple Docker hosts using Kubernetes.
  • Docker Commons Plugin — APIs for using Docker from other plugins.

其中,它们间的关系如下:

  • Docker commons Plugin为其他与Docker相关的插件提供了APIs
  • CloudBees Docker Build and Publish plugin和Docker build step plugin都依赖了Docker commons Plugin
  • Kubernetes Plugin依赖了Docker Plugin

坑:

在上图kitematic界面中点击右下侧任意一个路径,会弹出如图对话框,若选择Enable Volumes会发生四件坏事:

1.强制重启jenkins server,即便有job没有完成;

2.重启后需要重新安装jenkins插件;

3.导致jenkins无法使用DooD的docker命令。

3.admin用户的密码会改变。

所以切记任何时候使用jenkins容器不要点选enable volumes。

 

解决办法:

停止(删除)docker,重新运行以下命令并配置新的jenkins容器。

docker run -d -v /var/run/docker.sock:/var/run/docker.sock \

                -v $(which docker):/usr/bin/docker -p 8080:8080 myjenk

转载于:https://www.cnblogs.com/flasheryu/p/5728645.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值